:root {
  --bg: #f7f8f8;
  --panel: #ffffff;
  --text: #171717;
  --muted: #686f76;
  --line: #e2e5e8;
  --soft: #f1f3f5;
  --accent: #1A66D2;
  --accent-strong: #1552a8;
  --danger: #a33b36;
  --success: #2f6f4e;
  --shadow: 0 12px 34px rgba(20, 28, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

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

a:hover {
  text-decoration: underline;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
.rich-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 102, 210, 0.12);
  outline: none;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: #fff;
}

.login-box {
  width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
}

.login-box h1 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 22px;
  font-size: 24px;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
}

.brand img,
.login-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topnav form {
  margin: 0;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 24px 56px;
}

main.page.dashboard-page.dashboard-grid {
  width: min(1260px, calc(100vw - 48px));
  max-width: 1260px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 22px;
  align-items: start;
  width: 100%;
}

.workspace-rail {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: flex;
  justify-content: center;
  padding-top: 6px;
}

.dashboard-grid > .content-panel {
  grid-column: 2 / -1;
  min-width: 0;
  width: 100%;
}

.content-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
}

.section-heading,
.panel-head,
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.heading-actions,
.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-actions form {
  margin: 0;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h1,
.panel-head h2,
.modal-head h2,
.timeline-section h3 {
  margin: 0;
  letter-spacing: 0;
}

.section-heading h1 {
  font-size: 28px;
}

.section-heading p,
.breadcrumb,
.muted,
.contact-card small,
.workspace-card small {
  color: var(--muted);
}

.breadcrumb {
  margin: 0 0 6px;
  font-size: 13px;
}

.button,
.icon-button,
.round-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.button {
  min-height: 38px;
  gap: 7px;
  padding: 8px 13px;
  white-space: nowrap;
}

.button:hover,
.icon-button:hover,
.round-add:hover {
  background: var(--soft);
  text-decoration: none;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.button.subtle {
  background: var(--soft);
}

.button.danger,
.icon-button.danger {
  border-color: rgba(163, 59, 54, 0.35);
  color: var(--danger);
}

.button.danger:hover,
.icon-button.danger:hover {
  background: rgba(163, 59, 54, 0.08);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  flex: 0 0 auto;
}

.icon-button.link-button {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
}

.round-add {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 24px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 190px));
}

label,
.repeat-block {
  display: grid;
  gap: 7px;
}

.check-row {
  align-content: end;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
}

.check-row input {
  width: auto;
}

label span,
.field-label {
  color: #343a40;
  font-size: 13px;
  font-weight: 700;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.split-actions {
  justify-content: space-between;
}

.split-actions > div {
  display: flex;
  gap: 10px;
}

.inline-form {
  margin: 0;
}

.copy-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.title-row,
.section-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notice {
  border-radius: 8px;
  margin: 0 0 18px;
  padding: 11px 13px;
}

.notice.error {
  border: 1px solid rgba(163, 59, 54, 0.25);
  background: rgba(163, 59, 54, 0.08);
  color: var(--danger);
}

.notice.success {
  border: 1px solid rgba(47, 111, 78, 0.25);
  background: rgba(47, 111, 78, 0.08);
  color: var(--success);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  min-height: 110px;
}

.workspace-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.workspace-card,
.contact-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  color: var(--text);
}

.workspace-card:hover,
.contact-card:hover {
  border-color: #c9d0d7;
  box-shadow: var(--shadow);
  text-decoration: none;
}

.workspace-card span,
.contact-card span {
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.section-stack {
  display: grid;
  gap: 18px;
}

.supplier-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.supplier-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  border-top: 6px solid var(--section-color);
  background: #fff;
  padding: 14px 16px;
}

.supplier-section-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.supplier-section-head span,
.section-empty {
  color: var(--muted);
}

.section-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  flex: 0 0 auto;
}

.section-empty {
  padding: 18px;
}

.hidden-section-list {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
}

.hidden-section-list h2 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: 0;
}

.hidden-section-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hidden-section-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.hidden-section-item form {
  margin: 0;
}

.section-table {
  min-width: 900px;
}

.task-panel {
  margin-bottom: 18px;
  width: 100%;
}

.compact-heading {
  margin-bottom: 14px;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-list.compact {
  gap: 8px;
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.task-card.is-done {
  opacity: 0.68;
}

.task-card form {
  margin: 0;
}

.task-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.task-actions form {
  margin: 0;
}

.check-button {
  border-color: rgba(47, 111, 78, 0.35);
  color: var(--success);
}

.task-main {
  display: grid;
  gap: 6px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--muted);
  font-size: 12px;
}

.task-breadcrumb {
  font-size: 13px;
}

.task-body {
  margin-top: 4px;
}

.supplier-page {
  display: grid;
  gap: 18px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px;
}

.contact-card.badge-green {
  border-color: rgba(47, 111, 78, 0.45);
}

.lead-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  min-height: 28px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 0 10px;
  text-align: center;
}

.contact-card .lead-badge {
  color: #fff;
}

.lead-badge.badge-green {
  background: #2f6f4e;
}

.lead-badge.badge-orange {
  background: #c46b16;
}

.lead-badge.badge-red {
  background: #a33b36;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: #3d444c;
  font-size: 12px;
  padding: 2px 8px;
}

.repeat-list {
  display: grid;
  gap: 8px;
}

.repeat-row {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 8px;
}

.modal {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal.wide {
  width: min(860px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.22);
}

.timeline-section {
  display: grid;
  gap: 16px;
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 18px;
}

.timeline {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  border-left: 3px solid var(--line);
  padding-left: 12px;
}

.timeline time {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 7px 0;
}

.rich-link-popover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin: 8px 0;
}

.rich-link-popover input {
  min-width: 0;
}

.rich-editor,
.rich-output {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  height: auto;
  min-height: 130px;
  max-height: none;
  line-break: anywhere;
  overflow-wrap: anywhere !important;
  word-break: break-all;
  padding: 11px;
  white-space: pre-wrap;
}

.rich-editor {
  overflow: visible !important;
}

.rich-output {
  min-height: 0;
  background: #fbfbfb;
}

.rich-editor *,
.rich-output * {
  max-width: 100%;
  line-break: anywhere;
  overflow-wrap: anywhere !important;
  word-break: break-all;
}

.rich-editor a,
.rich-output a {
  display: inline;
  line-break: anywhere;
  overflow-wrap: anywhere !important;
  word-break: break-all;
}

.rich-output p:first-child,
.rich-output div:first-child {
  margin-top: 0;
}

.rich-output p:last-child,
.rich-output div:last-child {
  margin-bottom: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171717;
  color: #fff;
  opacity: 0;
  padding: 10px 13px;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .topbar,
  .section-heading,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav {
    justify-content: space-between;
  }

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

  .workspace-rail {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-start;
    padding-top: 0;
  }

  .dashboard-grid > .content-panel {
    grid-column: 1;
  }

  .page {
    padding: 20px 14px 42px;
  }

  .content-panel,
  .modal {
    padding: 16px;
  }

  .form-grid,
  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .split-actions,
  .split-actions > div {
    flex-direction: column-reverse;
  }

  .button,
  .heading-actions,
  .copy-field {
    width: 100%;
  }

  .task-card {
    grid-template-columns: 1fr;
  }

  .task-actions {
    justify-content: flex-start;
  }

  .section-actions {
    width: 100%;
  }

  .section-actions form {
    flex: 1 1 140px;
  }

  .supplier-section-head {
    align-items: stretch;
    flex-direction: column;
  }
}
