@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
:root {
  --ink:#0a2237;
  --navy:#0d375e;
  --blue:#106bc7;
  --soft:#eaf4fc;
  --canvas:#f6f7f9;
  --border:#e2e8f0;
  --text:#475569;
  --muted:#64748b;
  font-family:Inter,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  color:var(--ink);
  font-size:14px
}

* {
  box-sizing:border-box
}

body {
  margin:0;
  background:var(--canvas)
}

button,input,select,textarea {
  font:inherit
}

button,a,input,select,textarea {
  outline-offset:3px
}

:focus-visible {
  outline:3px solid var(--blue)
}

button {
  cursor:pointer
}

button {
  background:white;
  color:var(--ink);
  border:1px solid var(--border);
  border-radius:8px;
  padding:9px 14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px
}

button:hover {
  background:var(--canvas)
}

button.primary {
  background:var(--blue);
  color:white;
  border-color:var(--blue);
  border-radius:99px;
  padding:11px 20px
}

button.primary:hover {
  background:#0b58a5
}

svg {
  width:19px;
  height:19px;
  flex-shrink:0;
  vertical-align:middle
}

a {
  color:var(--blue);
  text-decoration:none
}

a:hover {
  text-decoration:underline
}

.sidebar {
  position:fixed;
  inset:0 auto 0 0;
  width:224px;
  background:white;
  border-right:1px solid var(--border);
  padding:32px 20px;
  display:flex;
  flex-direction:column
}

.brand {
  display:flex;
  align-items:center;
  gap:12px;
  margin:0 8px 44px
}

.logo {
  width:39px;
  height:43px;
  background:var(--navy);
  color:white;
  border-radius:12px 12px 18px 18px;
  display:grid;
  place-items:center
}

.brand strong {
  font-size:18px;
  letter-spacing:-.5px
}

.brand small {
  display:block;
  color:var(--muted);
  font-size:12px;
  margin-top:4px
}

.navlabel {
  font-size:11px;
  letter-spacing:1.6px;
  color:var(--muted);
  font-weight:600;
  margin:22px 14px 12px
}

.nav {
  width:100%;
  border:0;
  justify-content:flex-start;
  padding:12px 14px;
  margin:3px 0;
  color:var(--text);
  min-height:46px
}

.nav.active {
  color:var(--blue);
  background:var(--soft);
  font-weight:600;
  border: 1px solid #83b5e4;
}

.nav .count {
  margin-left:auto;
  font-size:12px;
  color:var(--muted)
}

.tagdot {
  width:8px;
  height:8px;
  background:#87a8c7;
  border-radius:50%;
  display:inline-block
}

.sidebarfoot {
  margin-top:auto;
  border-top:1px solid var(--border);
  padding-top:22px;
  display:flex;
  align-items:center;
  gap:10px
}

.avatar {
  width:36px;
  height:36px;
  display:inline-grid;
  place-items:center;
  border-radius:50%;
  background:var(--soft);
  color:var(--blue);
  font-size:12px;
  font-weight:600;
  flex-shrink:0
}

.sidebarfoot small {
  display:block;
  color:var(--muted);
  margin-top:4px;
  font-size:12px
}

.main {
  margin-left:224px
}

.topbar {
  height:72px;
  padding:0 36px;
  border-bottom:1px solid var(--border);
  background:white;
  display:flex;
  align-items:center;
  justify-content:space-between;
  color:var(--muted);
  font-size:13px
}

.topbar span {
  display:flex;
  align-items:center;
  gap:9px
}

.demo {
  background:#f2f5f8;
  border-radius:99px;
  padding:6px 11px;
  font-size:12px
}

.workspace {
  padding:34px 36px
}

.heading {
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:28px
}

h1 {
  font-size:30px;
  letter-spacing:-1px;
  margin:0 0 0;
  font-weight:600
}

p {
  color:var(--muted);
  line-height:1.6;
  margin:0
}

.actions {
  display:flex;
  gap:10px
}

.highlights {
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:16px;
  margin-bottom:28px
}

.highlight {
  background:white;
  border:1px solid var(--border);
  border-radius:12px;
  padding:19px 20px;
  display:flex;
  align-items:center;
  gap:14px;
  text-align:left;
  min-height:98px
}

.highlight:hover {
  border-color:#a5c9e7;
  background:white
}

.highlight.active {
  border-color:#83b5e4;
  background:#f5faff
}

.iconbox {
  width:42px;
  height:42px;
  background:var(--soft);
  border-radius:12px;
  display:grid;
  place-items:center;
  color:var(--blue);
  flex-shrink:0
}

.highlight:nth-child(3) .iconbox {
  background:#f2f2ed;
  color:#717656
}

.highlight strong {
  display:block;
  font-size:14px;
  font-weight:500;
  margin-bottom:6px
}

.highlight small {
  color:var(--muted);
  font-size:12px
}

.highlight b {
  font-size:25px;
  font-weight:600;
  margin-left:auto
}

.panel {
  background:white;
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden
}

.listtop {
  padding:0 24px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom:1px solid var(--border);
  gap:12px
}

.tabs {
  display:flex;
  gap:24px
}

.tab {
  border:0;
  border-radius:0;
  padding:18px 0;
  color:var(--muted);
  border-bottom:2px solid transparent
}

.tab.active {
  color:var(--blue);
  border-bottom-color:var(--blue);
  font-weight:600
}

.tab span {
  font-size:12px;
  padding:2px 7px;
  border-radius:99px;
  background:#f0f4f8
}

.toggle {
  display:flex;
  gap:3px;
  background:var(--canvas);
  padding:3px;
  border-radius:7px
}

.toggle button {
  min-height:31px;
  padding:5px 10px;
  border:0;
  background:transparent;
  color:var(--muted)
}

.toggle button.active {
  background:white;
  box-shadow:0 1px 4px #0a223712;
  color:var(--blue)
}

.filters {
  padding:20px 24px;
  display:flex;
  gap:10px
}

.search {
  flex:1;
  position:relative
}

.search svg {
  position:absolute;
  left:13px;
  top:13px;
  color:var(--muted)
}

input,select,textarea {
  border:1px solid #9baabd;
  background:white;
  color:var(--ink);
  border-radius:8px;
  min-height:44px;
  padding:10px 12px;
  max-width:100%
}

.search input {
  width:100%;
  padding-left:41px;
  border-color:#bac5d2
}

.filters select {
  border-color:#bac5d2;
  font-size:13px
}

.tablewrap {
  overflow:auto
}

table {
  border-collapse:collapse;
  width:100%;
  white-space:nowrap
}

th {
  font-size:12px;
  font-weight:500;
  background:#f8fafc;
  text-align:left;
  color:var(--muted);
  padding:13px 15px
}

td {
  padding:16px 15px;
  border-bottom:1px solid #edf0f4;
  font-size:13px;
  color:var(--text);
  height:76px
}

th:first-child,td:first-child {
  padding-left:24px;
  width:42px
}

tr:hover td {
  background:#fafcfe
}

tr.selected td {
  background:#f1f7fd
}

input[type=checkbox] {
  width:16px;
  height:16px;
  min-height:0;
  accent-color:var(--blue)
}

.person {
  display:flex;
  align-items:center;
  gap:12px;
  border:0;
  padding:0;
  background:transparent;
  text-align:left;
  min-height:36px;
  justify-content:flex-start
}

.person:hover {
  background:transparent
}

.person strong {
  font-size:16px;
  font-weight:500;
  color:var(--ink)
}

.person small {
  display:block;
  margin-top:5px;
  color:var(--muted);
  font-size:12px
}

.pill {
  display:inline-flex;
  border-radius:5px;
  background:#eaf2fa;
  color:#35638a;
  font-size:11px;
  padding:5px 8px;
  margin:2px 3px 2px 0;
  white-space:nowrap
}

.pill.past {
  background:#eef3eb;
  color:#56704a
}

.pill.friend {
  background:#f1edf7;
  color:#78658d
}

.pill.vendor {
  background:#f7efe4;
  color:#8c6b39
}

.foot {
  padding:17px 24px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  color:var(--muted);
  font-size:12px
}

.foot select {
  min-height:32px;
  padding:5px;
  font-size:12px;
  border-color:var(--border)
}

.foot div {
  display:flex;
  align-items:center;
  gap:8px
}

.subnote {
  margin:18px 2px;
  display:flex;
  justify-content:space-between;
  font-size:12px;
  color:var(--muted)
}

.drawer {
  position:fixed;
  right:0;
  top:0;
  bottom:0;
  width:398px;
  background:white;
  border-left:1px solid var(--border);
  box-shadow:-10px 0 32px #0a223708;
  overflow-y:auto;
  z-index:4
}

.withdrawer .workspace {
  margin-right:362px;
  padding-right:26px
}

.drawerhead {
  padding:20px 24px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-size:12px;
  color:var(--muted)
}

.iconbtn {
  border:0;
  padding:7px;
  min-height:32px
}

.profile {
  padding:10px 28px 24px;
  border-bottom:1px solid var(--border)
}

.profile .avatar {
  width:64px;
  height:64px;
  font-size:20px;
  margin-bottom:16px
}

.profile h2 {
  font-size:24px;
  letter-spacing:-.6px;
  margin:0 0 9px;
  font-weight:600
}

.profile .actions {
  margin-top:19px
}

.profile .actions button {
  flex:1;
  font-size:13px
}

.detailsection {
  padding:24px 28px;
  border-bottom:1px solid var(--border)
}

.detailsection h3 {
  margin:0 0 20px;
  font-size:14px;
  font-weight:600;
  display:flex;
  align-items:center;
  justify-content:space-between
}

.detail {
  display:flex;
  gap:13px;
  margin:19px 0;
  color:var(--muted)
}

.detail svg {
  width:17px;
  margin-top:3px
}

.detail small {
  display:block;
  font-size:12px;
  margin-bottom:6px
}

.detail span,.detail a {
  font-size:14px;
  line-height:1.65;
  color:var(--ink);
  overflow-wrap:anywhere
}

.dates {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px
}

.datebox {
  padding:13px;
  background:var(--canvas);
  border-radius:8px
}

.datebox small {
  display:block;
  color:var(--muted);
  font-size:11px;
  margin-bottom:8px
}

.datebox strong {
  font-size:13px;
  font-weight:500
}

.relation {
  display:flex;
  align-items:center;
  gap:12px;
  border:1px solid var(--border);
  padding:13px;
  border-radius:10px;
  width:100%;
  justify-content:flex-start
}

.relation small {
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-top:5px
}

.relation svg {
  margin-left:auto;
  color:var(--muted)
}

.relationhint {
  font-size:11px;
  line-height:1.6;
  color:var(--muted);
  margin-top:12px
}

.notes {
  font-size:14px;
  line-height:1.8;
  color:var(--text)
}

.cards {
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
  gap:16px;
  padding:8px 24px 24px
}

.contactcard {
  display:block;
  text-align:left;
  padding:20px;
  border-radius:12px
}

.contactcard .person {
  margin-bottom:18px
}

.contactcard p {
  font-size:13px;
  margin:12px 0
}

.empty {
  text-align:center;
  padding:60px 20px
}

.empty h3 {
  font-size:18px
}

.empty button {
  margin-top:18px
}

dialog {
  width:min(640px,calc(100% - 32px));
  border:1px solid var(--border);
  border-radius:16px;
  padding:0;
  color:var(--ink);
  max-height:90vh
}

dialog::backdrop {
  background:#0a22374d
}

dialog header {
  padding:24px;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between
}

dialog h2 {
  font-size:20px;
  margin:0
}

form {
  padding:24px
}

.formgrid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px
}

label.field {
  display:flex;
  flex-direction:column;
  gap:8px;
  font-size:13px
}

.wide {
  grid-column:1/-1
}

form footer {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:24px
}

textarea {
  min-height:90px;
  resize:vertical
}

#toast {
  position:fixed;
  bottom:24px;
  left:50%;
  transform:translateX(-50%);
  padding:12px 22px;
  background:var(--navy);
  color:white;
  border-radius:10px;
  z-index:10;
  display:none
}

.full .drawer {
  width:calc(100% - 224px);
  top:0;
  padding:20px max(32px,15%)
}

.full .profile {
  text-align:center
}

.full .profile .actions {
  max-width:300px;
  margin:20px auto 0
}

.full .detailsection {
  max-width:700px;
  margin:auto
}

.mobilebrand {
  display:none
}

.sort {
  border:0;
  background:transparent;
  font-size:12px;
  padding:0;
  min-height:0;
  color:var(--muted)
}

@media(min-width:1600px) {
  .workspace {
    max-width:1800px;
    margin:auto
  }

}

@media(max-width:1250px) {
  .sidebar {
    width:190px;
    padding:28px 14px
  }

  .main {
    margin-left:190px
  }

  .workspace {
    padding:28px 24px
  }

  .withdrawer .workspace {
    margin-right:0
  }

  .withdrawer .drawer {
    box-shadow:-12px 0 50px #0a223718
  }

  .full .drawer {
    width:calc(100% - 190px)
  }

}

@media(max-width:850px) {
  .sidebar {
    width:72px;
    padding:24px 10px
  }

  .brand {
    margin:0 6px 30px
  }

  .brand>div:last-child,.navlabel,.nav .navtext,.nav .count,.sidebarfoot>div:last-child,.sidebar .tag-nav {
    display:none
  }

  .nav {
    justify-content:center;
    padding:12px
  }

  .main {
    margin-left:72px
  }

  .topbar {
    padding:0 22px
  }

  .highlights {
    gap:10px
  }

  .highlight {
    padding:15px 12px;
    gap:9px
  }

  .highlight .iconbox {
    display:none
  }

  .highlight b {
    font-size:22px
  }

  .full .drawer {
    width:calc(100% - 72px)
  }

  .filters {
    flex-wrap:wrap
  }

  .search {
    flex-basis:100%
  }

  .heading .actions button {
    padding:10px 13px
  }

}

@media(max-width:600px) {
  .sidebar {
    display:none
  }

  .main {
    margin-left:0
  }

  .topbar {
    height:60px;
    padding:0 16px
  }

  .workspace {
    padding:24px 16px
  }

  .heading {
    align-items:flex-start;
    gap:12px
  }

  h1 {
    font-size:26px
  }

  .heading p {
    font-size:12px
  }

  .heading .actions {
    flex-direction:column
  }

  .heading .actions>button:first-child {
    display:none
  }

  .highlights {
    grid-template-columns:1fr 1fr
  }

  .highlight:first-child {
    display:none
  }

  .highlight {
    min-height:80px
  }

  .highlight strong {
    font-size:12px
  }

  .highlight small {
    font-size:11px
  }

  .listtop,.filters {
    padding-left:16px;
    padding-right:16px
  }

  .tabs {
    gap:18px
  }

  .toggle button {
    padding:6px
  }

  .toggle .viewtext {
    display:none
  }

  .drawer,.full .drawer {
    top:0;
    width:100%;
    padding:0;
    z-index:6
  }

  .subnote span:last-child {
    display:none
  }

  .formgrid {
    grid-template-columns:1fr
  }

  .wide {
    grid-column:auto
  }

  .foot {
    gap:12px;
    flex-wrap:wrap
  }

  .filters select {
    flex:1;
    min-width:0
  }

  .highlight b {
    font-size:22px
  }

  .topbar .crumb {
    font-size:12px
  }

}

.heading-title {
  display:flex;
  align-items:center;
  gap:20px;
  flex-wrap:wrap
}

.heading-title h1 {
  margin:0
}

.heading {
  gap:16px
}

.heading-title .primary {
  flex-shrink:0
}

@media(max-width:600px) {
  .heading-title {
    gap:12px
  }

  .heading-title .primary {
    padding:10px 14px
  }

}

.selectionbar {
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  padding:12px 24px;
  background:var(--soft);
  border-top:1px solid #d5e6f5;
  border-bottom:1px solid #d5e6f5
}

.selectionbar strong {
  font-size:13px;
  font-weight:500;
  margin-right:12px
}

.selectionbar button {
  min-height:36px;
  padding:7px 12px
}

.selectionbar .danger {
  color:#b02525
}

.selectionbar .clear-selection {
  margin-left:auto;
  background:transparent;
  border-color:transparent;
  color:var(--blue)
}

.addresscell small {
  display:block;
  margin-top:5px;
  color:var(--muted);
  font-size:12px
}

.note-preview {
  display:block;
  max-width:240px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  border:0;
  padding:0;
  min-height:36px;
  color:var(--text);
  text-align:left;
  background:transparent
}

td a {
  color:var(--text)
}

.tablewrap table {
  min-width:0
}

#toast button {
  margin-left:14px;
  min-height:30px;
  padding:4px 10px
}

@media(max-width:600px) {
  .selectionbar {
    padding:12px 16px
  }

  .selectionbar .clear-selection {
    margin-left:0
  }

}

tr[data-row-contact] {
  cursor:pointer
}

.table-toolbar {
  position:relative
}

.table-toolbar.has-selection .filters {
  visibility:hidden;
  pointer-events:none
}

.table-toolbar .selectionbar {
  position:absolute;
  inset:0;
  margin:0;
  border-top:0;
  border-bottom:0;
  align-content:center
}

/* Keep workspace controls in place; only records scroll. */
.main {
  height:100dvh;
  overflow:hidden
}

.workspace {
  height:100%;
  display:flex;
  flex-direction:column;
  min-height:0
}

.heading,.highlights,.subnote {
  flex-shrink:0
}

.panel {
  display:flex;
  flex-direction:column;
  flex:1;
  min-height:0
}

.listtop,.table-toolbar,.foot {
  flex-shrink:0
}

.tablewrap,.cards,.empty {
  flex:1;
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain
}

.cards {
  align-content:start
}

.tablewrap th {
  position:sticky;
  top:0;
  z-index:1;
  box-shadow:0 1px 0 var(--border)
}

.sidebar {
  overflow-y:auto
}

@media(max-height:700px) {
  .highlights,.subnote {
    display:none
  }

  .workspace {
    padding-top:16px;
    padding-bottom:16px
  }

  .heading {
    margin-bottom:16px
  }

  .filters {
    padding-top:12px;
    padding-bottom:12px
  }

}

/* Fit all contact columns inside the workspace without sideways scrolling. */
.tablewrap {
  overflow-x:hidden;
  overflow-y:auto
}

.tablewrap table {
  width:100%;
  table-layout:fixed;
  white-space:normal
}

.tablewrap th,.tablewrap td {
  padding-left:10px;
  padding-right:10px;
  overflow-wrap:anywhere
}

.tablewrap th:first-child,.tablewrap td:first-child {
  width:40px;
  padding-left:14px;
  padding-right:8px
}

.tablewrap th:nth-child(2) {
  width: 28%;
}

.tablewrap th:nth-child(3) {
  width: 18%;
}

.tablewrap th:nth-child(4) {
  width: 27%;
}

.tablewrap th:nth-child(5) {
  width: auto;
}

.tablewrap .person {
  width: 100%;
  min-width: 0;
}

.tablewrap .person>span:last-child {
  min-width:0
}

.tablewrap .person strong,.tablewrap .person small {
  overflow-wrap:anywhere;
  white-space:normal
}

.tablewrap .pill {
  max-width:100%;
  white-space:normal;
  overflow-wrap:anywhere
}

.tablewrap .note-preview {
  width:100%;
  max-width:100%;
  white-space:normal;
  overflow-wrap:anywhere;
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden
}

.tablewrap .addresscell small {
  overflow-wrap:anywhere
}

@media(max-width:600px) {
  .tablewrap th,.tablewrap td {
    padding-left:4px;
    padding-right:4px
  }

  .tablewrap th:first-child,.tablewrap td:first-child {
    width:28px;
    padding-left:6px;
    padding-right:4px
  }

  .tablewrap .person {
    flex-direction:column;
    align-items:flex-start;
    gap:6px
  }

}

.search:has(.clear-search) input {
  padding-right: 132px;
}

.clear-search {
  position: absolute;
  right: 6px;
  top: 4px;
  min-height: 36px;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
}

.clear-search:hover {
  background:var(--soft)
}

/* Consistent right inset for native dropdown indicators. */
select {
  appearance:none;
  -webkit-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 10px center;
  padding-right:34px
}

.foot select {
  padding-right:34px
}

.contact-dialog {
  width:min(700px,calc(100% - 32px))
}

.contact-form {
  grid-template-columns:1fr;
  gap:16px
}

.formrow {
  display:grid;
  gap:16px;
  min-width:0
}

.formrow.two {
  grid-template-columns:repeat(2,minmax(0,1fr))
}

.formrow.three {
  grid-template-columns:repeat(3,minmax(0,1fr))
}

.formrow.one {
  grid-template-columns:minmax(0,1fr)
}

.formrow.address-row {
  grid-template-columns:2fr 1fr 1fr
}

.contact-form .field {
  min-width:0
}

.contact-form input {
  width:100%;
  min-width:0
}

.contact-form textarea {
  min-height:72px
}

.contact-dialog header {
  padding:20px 24px
}

.contact-dialog form {
  padding:20px 24px
}

.contact-dialog form footer {
  margin-top:20px
}

@media(max-width:600px) {
  .formrow.two,.formrow.three {
    grid-template-columns:minmax(0,1fr)
  }

  .formrow.address-row {
    grid-template-columns:minmax(0,1fr)
  }

  .contact-dialog form,.contact-dialog header {
    padding:16px
  }

}

.tablewrap td {
  font-size:14px
}

.tablewrap .person strong {
  font-size:16px
}

.tablewrap .addresscell small {
  font-size:13px
}

.tablewrap .note-preview {
  font-size:14px
}

.sidebar .nav {
  min-height:38px;
  padding:8px 14px;
  margin:2px 0
}

.sidebar .brand {
  margin-bottom:60px
}

.sidebar .navlabel {
  margin-top:50px;
  margin-bottom:8px
}

@media(max-width:850px) {
  .sidebar .nav {
    padding:8px
  }

  .sidebar .brand {
    margin-bottom:20px
  }

}

/* Blue gradient initials shared across contact views. */
.avatar {
  background:linear-gradient(135deg,#4baff0 0%,#287dde 55%,#1759c5 100%);
  color:#fff
}

/* Swift, consistent hover feedback without animating layout. */
button,a,input,select,textarea,.nav,.highlight,.pill,.avatar,.tablewrap td {
  transition:background-color 150ms ease-out,color 150ms ease-out,border-color 150ms ease-out,box-shadow 150ms ease-out;
}

@media(prefers-reduced-motion:reduce) {
  button,a,input,select,textarea,.nav,.highlight,.pill,.avatar,.tablewrap td {
    transition:none
  }

}

.drawerhead #close {
  width:44px;
  height:44px;
  min-height:44px;
  padding:12px;
  border-radius:50%;
  background:var(--soft);
  color:var(--blue);
  border:1px solid #d5e6f5
}

.drawerhead #close:hover {
  background:#d8ebfb;
  border-color:#a5c9e7
}

/* Contact panel actions and modal elevation. */
dialog#editor {
  box-shadow:0 24px 70px rgba(10,34,55,.18),0 6px 20px rgba(10,34,55,.08)
}

.profile .actions #edit {
  flex:0 0 165px;
  width:165px;
  max-width:100%
}

#linkcontact {
  background:transparent;
  border:0;
  border-radius:4px;
  padding:8px 0;
  color:var(--blue);
  text-decoration:underline;
  text-underline-offset:3px;
  box-shadow:none
}

#linkcontact:hover {
  background:transparent;
  color:#0b58a5
}

/* Tag management */
.tags-dialog {
  width: min(600px, calc(100% - 32px));
}
.tag-manager {
  padding: 24px;
}
.tag-manager-intro, .tag-manager-summary, .tag-editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tag-manager-intro {
  justify-content: space-between;
  margin-bottom: 20px;
}
.tag-manager-intro p {
  margin: 0;
  color: var(--muted);
  max-width: 260px;
}
.tag-manager-intro button {
  flex-shrink: 0;
}
.tag-manager-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}
.tag-manager-summary {
  padding: 12px 16px;
}
.tag-manager-summary .pill, .tag-live-preview {
  font-size: 13px;
  overflow-wrap: anywhere;
}
.tag-usage {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.tag-editor {
  padding: 20px 16px;
  background: var(--canvas);
  border-top: 1px solid var(--border);
}
.tag-colors {
  border: 0;
  padding: 0;
  margin: 20px 0;
}
.tag-colors legend {
  font-size: 13px;
  margin-bottom: 10px;
}
.tag-colors > div {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tag-swatch {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-weight: 600;
}
.tag-swatch[aria-pressed="true"] {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.tag-preview-line {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tag-editor-actions {
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}
.tag-delete {
  margin-right: auto;
  border-color: transparent;
  background: transparent;
}
.tag-delete-confirm {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #e6b9b9;
  border-radius: 8px;
  background: #fff5f5;
}
.tag-delete-confirm p {
  margin-top: 0;
}
.tag-delete-confirm button + button {
  margin-left: 8px;
}
.tags-dialog button:disabled,
.tags-page button:disabled {
  opacity: .45;
  cursor: default;
}

/* Dedicated tag management page */
.tags-page .tag-manager {
  width: 100%;
  max-width: 880px;
  min-height: 0;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tags-page .tag-manager-intro p {
  max-width: none;
}
.tags-page .tag-editor .field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (max-width: 600px) {
  .heading > #newtag {
    padding: 10px;
  }
  .tags-page .tag-manager {
    padding: 16px;
  }
}

/* Longer tags stay within the expanded Tags column. */
.tablewrap .pill {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Keep page navigation close to its heading. */
.tags-page > .heading {
  justify-content: flex-start;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.back-arrow {
  display: inline-flex;
  transform: rotate(180deg);
}
.sidebar .nav {
  text-align: left;
}
.sidebar .navtext {
  white-space: nowrap;
  text-align: left;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .nav .count:empty {
  display: none;
}

/* Searchable contact label picker */
.label-picker { position: relative; min-width: 0; font-size: 13px; }
.label-picker > label { display: block; margin-bottom: 8px; }
.label-control { border: 1px solid #9baabd; border-radius: 8px; background: white; padding: 6px; }
.label-control:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.contact-form .label-control input { border: 0; min-height: 32px; padding: 4px; outline: none; }
.label-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.label-chip { display: inline-flex; align-items: center; max-width: 100%; overflow-wrap: anywhere; border-radius: 5px; padding: 2px 5px; }
.label-chip button { border: 0; background: transparent; padding: 0 4px; color: inherit; font-size: 18px; }
.label-picker [role="listbox"] { position: absolute; top: 100%; left: 0; width: 100%; max-width: 85vw; max-height: 200px; overflow: auto; z-index: 20; background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px #0a223720; }
.label-picker [role="option"] { padding: 8px 12px; cursor: pointer; }
.label-picker [role="option"]:hover, .label-picker [aria-selected="true"] { background: var(--soft); }
.label-create { border-top: 1px solid var(--border); color: var(--blue); font-weight: 600; }
.label-status { display: block; color: var(--muted); }
.label-no-results { padding: 12px; color: var(--muted); }
.label-picker [hidden] {
  display: none !important;
}

/* Preserve readable columns; scroll the table within the shrinking workspace. */
.main, .workspace, .panel, .table-toolbar {
  min-width: 0;
}
.tablewrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.tablewrap table {
  min-width: 960px;
}
@media (max-width: 600px) {
  .sidebar {
    display: flex;
    position: relative;
    inset: auto;
    width: 100%;
    height: 60px;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand, .sidebar .sidebarfoot, .sidebar .count {
    display: none;
  }
  .sidebar .nav {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
    padding: 8px 10px;
  }
  .sidebar .navtext {
    display: inline;
    overflow: visible;
  }
  .main {
    margin-left: 0;
    height: calc(100dvh - 60px);
  }
  .workspace {
    padding: 16px 10px;
  }
  .withdrawer .workspace {
    margin-right: 0;
    padding-right: 10px;
  }
  .heading {
    margin-bottom: 16px;
  }
  .highlights, .subnote {
    display: none;
  }
  .listtop, .filters, .foot {
    padding-left: 12px;
    padding-right: 12px;
  }
  .listtop {
    gap: 8px;
  }
  .tabs {
    gap: 12px;
  }
  .filters {
    gap: 8px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .search {
    min-width: 0;
  }
  .foot {
    gap: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .selectionbar {
    padding: 10px 12px;
    gap: 8px;
    align-content: center;
  }
  .tablewrap th, .tablewrap td {
    padding-left: 10px;
    padding-right: 10px;
  }
  .tablewrap th:first-child, .tablewrap td:first-child {
    width: 40px;
    padding-left: 14px;
    padding-right: 8px;
  }
  .tablewrap .person {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  .tag-manager-intro {
    flex-wrap: wrap;
  }
  input, select, textarea {
    font-size: 16px;
  }
}

/* Team settings preview — uses the CRM's shared colors and controls. */
.settings-page {
  overflow-y: auto;
  display: block;
}
.settings-notice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px;
  margin-bottom: 24px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--navy);
  line-height: 1.5;
}
.settings-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}
.settings-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.settings-panel p {
  color: var(--muted);
  line-height: 1.6;
}
.settings-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.team-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}
.team-person {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.team-person small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}
.team-status, .team-owner-note {
  color: var(--muted);
  font-size: 12px;
}
.role-guide {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 24px;
}
.role-guide p {
  margin-bottom: 0;
  font-size: 13px;
}
.team-dialog {
  width: min(560px, calc(100% - 24px));
}
.team-dialog .field {
  margin-bottom: 18px;
}
.team-preview-note {
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 22px;
}
.team-permissions {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 0;
}
.team-permissions p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.permission-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.team-error {
  color: #a32626;
}
@media (max-width: 700px) {
  .settings-panel { padding: 16px; }
  .settings-section-heading, .team-row { flex-wrap: wrap; }
  .team-person { flex-basis: calc(100% - 60px); }
  .role-guide { grid-template-columns: 1fr 1fr; }
  .settings-page .heading-title { flex-wrap: wrap; }
  .team-dialog footer { flex-wrap: wrap; }
}
.team-dialog {
  min-height: 0;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.team-dialog footer {
  margin-top: 16px;
}
.team-dialog .permission-option {
  padding: 5px 0;
}

/* Authentication uses the same form and surface tokens as the CRM. */
.signin-page {
  min-height: 80dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.signin-panel {
  width: min(440px, 100%);
  box-sizing: border-box;
}
.signin-layout {
  width: min(464px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.signin-logo {
  width: 72px;
  height: auto;
  display: block;
}
.signin-layout .signin-panel {
  width: 90%;
  padding: clamp(24px, 4vw, 42px);
  border-radius: 20px;
  box-shadow: 0 10px 36px rgba(13, 55, 94, 0.055), 0 2px 8px rgba(13, 55, 94, 0.025);
}
.signin-panel form {
  padding: 16px 0;
}
.signin-panel .field {
  margin-bottom: 20px;
}
.signin-panel small {
  color: var(--muted);
  line-height: 1.5;
}
[hidden] { display: none !important; }

/* Password sign-in and account recovery. */
.signin-panel .field { margin-bottom: 18px; }
.auth-link { color: var(--blue); background: transparent; border: 0; padding: 8px 0; text-decoration: underline; text-align: left; }
.auth-link:hover { background: transparent; }

.password-input { position: relative; }
.password-input input { width: 100%; padding-right: 72px; }
.password-toggle { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); padding: 8px; border: 0; background: transparent; color: var(--blue); font-size: 13px; }

/* Guided CSV import. */
dialog.import-dialog { width: min(1100px, calc(100vw - 32px)); }
.import-body { padding: 24px; }
.import-body > p { color: var(--muted); line-height: 1.5; }
.import-file { margin-top: 24px; }
.import-preview { max-height: 360px; overflow: auto; margin: 20px 0; border: 1px solid var(--border); border-radius: 8px; }
.import-preview table { min-width: 800px; white-space: normal; }
.import-preview td { height: auto; padding: 12px; overflow-wrap: anywhere; }
.import-preview th { position: sticky; top: 0; }
.import-approval { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.import-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* Inline authentication progress. */
.auth-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: auth-spin 650ms linear infinite;
}
@keyframes auth-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .auth-spinner { animation: none; }
}
