:root {
  --sidebar: #303332;
  --sidebar-dark: #242726;
  --bg: #f4f8fb;
  --panel: #ffffff;
  --border: #dde9ef;
  --text: #29302f;
  --muted: #68777c;
  --accent: #8fc2d7;
  --danger: #c83f45;
  --soft-accent: #edf7fb;
  --accent-dark: #2f3433;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body.is-locked .sidebar,
body.is-locked .app {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(244, 248, 251, 0.9);
  backdrop-filter: blur(10px);
}

.login-screen.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.login-box {
  width: min(100%, 380px);
  display: grid;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(41, 48, 47, 0.18);
}

.login-box img {
  width: 92px;
  height: 92px;
  margin: 0 auto;
  border-radius: 0;
  object-fit: contain;
}

.login-box h1 {
  margin: 0;
  text-align: center;
  font-size: 22px;
}

.login-box p {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

.fake-login-field {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.role-label {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--muted);
  background: #f7fbfd;
  font-size: 12px;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 13px;
  color: var(--text);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.link-button:hover {
  color: var(--text);
  text-decoration: underline;
}

body.sidebar-collapsed .sidebar {
  width: 68px;
  flex-basis: 68px;
  padding: 12px 6px;
}

body.sidebar-collapsed .brand {
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 0 0 10px;
  min-height: 58px;
}

body.sidebar-collapsed .brand div,
body.sidebar-collapsed .nav-item > span:not(.nav-icon),
body.sidebar-collapsed .sidebar-toggle > span:not(.nav-icon) {
  display: none;
}

body.sidebar-collapsed .brand img {
  width: 46px;
  height: 46px;
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  min-height: 42px;
  padding: 0;
  font-size: 17px;
}

body.sidebar-collapsed .sidebar-toggle {
  justify-content: center;
  padding: 0;
}

.sidebar {
  width: 232px;
  height: 100vh;
  flex: 0 0 232px;
  overflow-y: auto;
  padding: 16px 8px;
  color: #fff;
  background: linear-gradient(180deg, #383b3a 0%, var(--sidebar) 52%, #292d2c 100%);
}

.brand {
  display: flex;
  align-items: center;
  position: relative;
  gap: 8px;
  padding: 0 8px 18px;
  font-size: 15px;
}

.sidebar-toggle {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: var(--sidebar-dark);
  box-shadow: inset 3px 0 0 var(--accent);
}

.brand img {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 0;
  object-fit: contain;
  box-shadow: none;
}

.brand div {
  display: grid;
  gap: 2px;
}

.brand span {
  color: #b9ddeb;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

nav {
  display: grid;
  gap: 2px;
}

.nav-item {
  position: relative;
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: #fff;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.nav-icon {
  width: 24px;
  display: inline-grid;
  place-items: center;
  color: #b9ddeb;
  font-size: 18px;
  line-height: 1;
}

.nav-item::after {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  z-index: 40;
  transform: translateY(-50%);
  border-radius: 6px;
  padding: 6px 9px;
  color: #fff;
  background: #242726;
  content: attr(data-label);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.05s ease;
}

.nav-hint {
  position: fixed;
  z-index: 40;
  left: 78px;
  top: 100px;
  display: none;
  border-radius: 6px;
  padding: 7px 10px;
  color: #fff;
  background: #242726;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.nav-hint.show {
  display: block;
}

.nav-item:hover::after,
.nav-item:focus-visible::after,
.nav-item.show-label::after {
  opacity: 1;
}

.nav-item.active,
.nav-item:hover {
  background: var(--sidebar-dark);
  box-shadow: inset 3px 0 0 var(--accent);
}

.app {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.primary-button,
.danger-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  color: #1f2728;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(143, 194, 215, 0.22);
}

.danger-button {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 32px;
}

.toolbar input {
  width: min(420px, 100%);
}

.page-section {
  padding: 0 32px 32px;
}

.note-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fcfe 0%, #eef7fb 100%);
}

.note-composer textarea {
  min-height: 110px;
  resize: vertical;
  font-size: 15px;
}

.note-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 0;
}

.note-toolbar input {
  width: min(440px, 100%);
}

.note-tabs {
  display: flex;
  gap: 6px;
}

.note-tab {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.note-tab.active {
  background: var(--accent);
}

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

.note-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(31, 45, 78, 0.04);
}

.note-card.done {
  opacity: 0.68;
}

.note-card p {
  margin: 0 0 8px;
  white-space: pre-wrap;
}

.note-card time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.note-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.note-card button {
  align-self: start;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: #eef7fb;
  font-weight: 700;
  cursor: pointer;
}

.note-card [data-note-action="delete"] {
  color: var(--danger);
  background: #fff7f7;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--text);
  background: #f9fbff;
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.masked-entry {
  font-family: inherit;
  letter-spacing: 0;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(143, 194, 215, 0.16);
}

input.invalid {
  border-color: var(--danger);
  background: #fff7f7;
}

small {
  color: var(--muted);
  font-weight: 400;
}

small.error {
  color: var(--danger);
  font-weight: 700;
}

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

.field-with-button button {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  background: #eef3ff;
  font-weight: 700;
  cursor: pointer;
}

.copy-field {
  position: relative;
}

.copy-field button {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent-dark);
  background: #eef7fb;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.copy-field button.copied {
  background: var(--accent);
}

.copy-field input {
  padding-right: 42px;
}

.address-box {
  display: grid;
  gap: 8px;
}

.address-grid {
  display: grid;
  grid-template-columns: 110px minmax(140px, 1fr) minmax(180px, 1.4fr) 100px;
  gap: 8px;
}

.address-grid label {
  gap: 5px;
  font-size: 12px;
}

.suggestions {
  display: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.suggestions.open {
  display: grid;
}

.suggestion {
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.suggestion:hover {
  background: #edf2ff;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  position: relative;
  padding: 0;
  overflow-x: auto;
}

.dealer-list,
.detail-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.dealer-list {
  min-width: 980px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(31, 45, 78, 0.05);
}

.list-head,
.dealer-row {
  display: grid;
  grid-template-columns: 120px 1.35fr 1fr 130px 1.25fr;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
}

.list-head {
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}

.dealer-row {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.dealer-row.active,
.dealer-row:hover {
  background: var(--soft-accent);
}

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 10;
  min-width: 430px;
  width: min(680px, 92vw);
  max-width: calc(100vw - 24px);
  height: 100vh;
  overflow: auto;
  padding: 0;
  border-radius: 0;
  box-shadow: -18px 0 40px rgba(23, 35, 63, 0.16);
}

.panel-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  width: 10px;
  cursor: ew-resize;
  background: transparent;
}

.panel-resizer:hover {
  background: rgba(143, 194, 215, 0.28);
}

.detail-panel.is-hidden {
  display: none;
}

.panel-title {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  margin-bottom: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.panel-heading {
  display: grid;
  gap: 4px;
  text-align: center;
}

.panel-heading h2 {
  font-size: 18px;
}

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

.back-button {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  background: #f9fbff;
  font-weight: 700;
  cursor: pointer;
}

#selectedId {
  color: var(--muted);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 640px;
  padding: 20px;
}

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

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.linked-area {
  margin: 8px 20px 22px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.mini-table {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.mini-table div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcff;
}

.mini-table span {
  color: var(--muted);
}

@media (max-width: 720px) {
  body {
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    width: 68px;
    flex-basis: 68px;
    padding: 12px 6px;
  }

  .app {
    height: 100vh;
    overflow-y: auto;
  }

  .brand {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 0 0 10px;
    min-height: 58px;
  }

  .brand div,
  .nav-item > span:not(.nav-icon),
  .sidebar-toggle > span:not(.nav-icon) {
    display: none;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .nav-item {
    justify-content: center;
    min-height: 42px;
    padding: 0;
    font-size: 17px;
  }

  .sidebar-toggle {
    justify-content: center;
    padding: 0;
  }

  body.sidebar-expanded .sidebar {
    width: 232px;
    flex-basis: 232px;
    padding: 16px 8px;
  }

  body.sidebar-expanded .brand {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 8px 18px;
    min-height: 0;
  }

  body.sidebar-expanded .brand div,
  body.sidebar-expanded .nav-item > span:not(.nav-icon),
  body.sidebar-expanded .sidebar-toggle > span:not(.nav-icon) {
    display: grid;
  }

  body.sidebar-expanded .nav-item,
  body.sidebar-expanded .sidebar-toggle {
    justify-content: flex-start;
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

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

@media (max-width: 620px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .workspace,
  .topbar,
  .toolbar,
  .page-section {
    padding-left: 16px;
    padding-right: 16px;
  }

  .note-composer {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .note-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .list-head,
  .dealer-row {
    grid-template-columns: 120px 1.35fr 1fr 130px 1.25fr;
  }
}
