@import url("./design/brand-tokens.css?v=3");
@import url("./design/theme.css?v=3");
@import url("./design/components.css?v=3");
@import url("./design/shell-layout.css?v=3");
@import url("./design/mobile-field.css?v=3");
@import url("./design/phase3-screens.css?v=2");
@import url("./design/phase3-kzm-light.css?v=1");

/* Aura Systems brand — same tokens as checksite/assets/css/styles.css (:root dark theme) */
:root {
  --bg: #060607;
  --text: #f1f2f4;
  --text-heading: #f5f6f8;
  --text-secondary: rgba(255, 255, 255, 0.88);
  --muted: #b0b3b9;
  --label-muted: #8e939c;
  --sep-muted: #6a6f78;
  --accent: #d90012;
  --accent-dark: #a7000d;
  --accent-gradient-top: #f31f2f;
  --accent-tint: rgba(217, 0, 18, 0.14);
  --accent-tint-strong: rgba(217, 0, 18, 0.22);
  --link: #ffb3b9;
  --link-hover: #ffc9cd;
  --line: rgba(255, 255, 255, 0.1);
  --border-muted: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.22);
  --panel-bg: rgba(255, 255, 255, 0.035);
  --surface: #111214;
  --surface-deep: #0a0b0d;
  --surface-raised: rgba(255, 255, 255, 0.055);
  --surface-ghost: rgba(255, 255, 255, 0.08);
  --hover-surface: rgba(255, 255, 255, 0.07);
  --shadow-accent: 0 12px 26px rgba(217, 0, 18, 0.28);
  --radius-card: 18px;
  --radius-input: 12px;
}

body {
  margin: 0;
  min-width: 320px;
  isolation: isolate;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(217, 0, 18, 0.18), transparent 22%),
    radial-gradient(circle at 85% 8%, rgba(255, 255, 255, 0.05), transparent 18%),
    linear-gradient(180deg, #0a0a0b 0%, #040404 52%, #09090a 100%);
  background-color: var(--bg);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.055;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 86%);
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.container.portal-has-shell {
  max-width: 1440px;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

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

input,
select,
button,
textarea {
  padding: 10px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border-strong);
  background: var(--surface-deep);
  color: var(--text);
}

select option,
select optgroup {
  background: var(--surface-deep);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(217, 0, 18, 0.55);
  outline-offset: 2px;
}

select:disabled,
input:disabled {
  background: var(--surface);
  color: var(--muted);
}

button {
  cursor: pointer;
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--accent-gradient-top) 0%, var(--accent) 100%);
  box-shadow: var(--shadow-accent);
  color: #fff;
  font-weight: 650;
  letter-spacing: 0.04em;
}

button:hover {
  filter: brightness(1.06);
}

button.secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  box-shadow: none;
  color: var(--text);
  font-weight: 600;
  letter-spacing: normal;
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.07);
  filter: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border-muted);
  padding: 8px 6px;
  text-align: left;
  font-size: 14px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
}

.nav-link {
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--radius-input);
  color: var(--text-secondary);
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.inventory-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.inventory-sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
}

.inventory-tree-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: transparent;
  border: 1px solid var(--border-muted);
  margin: 4px 4px 4px 0;
  min-width: 40px;
}

.inventory-tree-link.active {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.tree-line {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tree-line .inventory-tree-link.label {
  flex: 1;
  justify-content: flex-start;
  text-align: left;
}

[data-edit-id] {
  min-width: 44px;
  font-size: 16px;
  padding: 8px 10px;
}

.button-like {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 8px;
  padding: 10px;
}

.inventory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inventory-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-dialog {
  width: min(980px, 95vw);
  max-height: 90vh;
  overflow: auto;
}

.modal-dialog form .row > input,
.modal-dialog form .row > select,
.modal-dialog form .row > label {
  flex: 1 1 180px;
}

.modal-dialog form .row > label select {
  width: 100%;
}

.modal-header {
  justify-content: space-between;
  align-items: center;
}

.quote-details {
  background: var(--surface-deep);
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  padding: 10px 12px;
}

.quote-details ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

@media (max-width: 1000px) {
  .inventory-layout {
    grid-template-columns: 1fr;
  }
  .inventory-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* --- Оболочка портала (sidebar + контент) --- */

.portal-app {
  display: flex;
  gap: 0;
  align-items: stretch;
  min-height: calc(100vh - 40px);
}

.portal-sidebar {
  position: relative;
  width: 260px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border: 1px solid var(--border-muted);
  border-radius: 12px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  padding: 8px 10px;
  color: var(--text-heading);
  letter-spacing: 0.02em;
}

.portal-sidebar-brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(217, 0, 18, 0.45);
}

.portal-nav-group {
  margin-top: 6px;
}

.portal-nav-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--label-muted);
  padding: 6px 10px 4px;
}

.portal-nav-link {
  display: block;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.portal-nav-link:hover {
  background: var(--hover-surface);
}

.portal-nav-link.active,
a.portal-nav-link[data-nav-key].active {
  background: var(--accent);
  color: #fff;
}

.portal-sidebar-logout {
  width: 100%;
  margin-top: auto;
}

.portal-sidebar-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--surface-ghost);
  border: 0;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
}

.portal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-main-inner {
  flex: 1;
  min-width: 0;
}

.portal-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border-muted);
  border-radius: 12px;
}

.portal-menu-toggle {
  display: none;
}

.portal-breadcrumb {
  flex: 1 1 180px;
  font-size: 14px;
  color: var(--muted);
}

.portal-breadcrumb a {
  color: var(--link);
  text-decoration: none;
}

.portal-bc-sep {
  margin: 0 6px;
  color: var(--sep-muted);
}

.portal-search-form input[type="search"] {
  min-width: 200px;
  max-width: 360px;
  width: 28vw;
}

.portal-user {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

body.density-compact .card {
  padding: 12px;
  margin-bottom: 12px;
}

body.density-compact th,
body.density-compact td {
  padding: 6px 4px;
  font-size: 13px;
}

.portal-sidebar-backdrop {
  display: none;
}

@media (max-width: 960px) {
  .portal-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(8, 10, 14, 0.55);
    backdrop-filter: blur(2px);
  }

  body.portal-sidebar-open .portal-sidebar-backdrop {
    display: block;
  }

  .portal-app {
    flex-direction: column;
  }

  .portal-sidebar {
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 92vw);
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    padding-top: 48px;
  }

  body.portal-sidebar-open .portal-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.45);
  }

  .portal-sidebar-close {
    display: block;
  }

  .portal-menu-toggle {
    display: inline-flex;
  }

  .portal-search-form {
    flex: 1 1 100%;
  }

  .portal-search-form input[type="search"] {
    width: 100%;
    max-width: none;
  }
}

/* --- Страница входа (без оболочки портала) --- */

body.portal-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.portal-login {
  width: 100%;
  max-width: 420px;
}

.portal-login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--label-muted);
  margin: 0 0 8px;
}

.portal-login-brand::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(217, 0, 18, 0.45);
}

.portal-login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}

.portal-login-lead {
  margin: 0 0 20px;
  font-size: 14px;
}

.portal-login-card .row {
  flex-direction: column;
  align-items: stretch;
}

@media (min-width: 480px) {
  .portal-login-card .row {
    flex-direction: row;
    align-items: flex-end;
  }
}

.portal-login-card input[name="username"],
.portal-login-card input[name="password"] {
  flex: 1;
  min-width: 0;
}

.portal-login-meta {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.45;
}

.portal-login-back {
  margin-top: 20px;
  font-size: 14px;
}

.portal-login-back a {
  color: var(--link);
}

/* --- Drawer предпросмотра сделки --- */

.portal-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 380;
  background: rgba(8, 10, 14, 0.55);
  backdrop-filter: blur(2px);
}

.portal-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 381;
  width: min(440px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-left: 1px solid var(--border-muted);
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.35);
}

.portal-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-muted);
}

.portal-drawer-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.portal-drawer-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--hover-surface);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.portal-drawer-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-size: 14px;
  line-height: 1.45;
}

.portal-drawer-body p {
  margin: 0 0 10px;
}

.portal-drawer-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border-muted);
}

body.deal-drawer-open {
  overflow: hidden;
}

/* --- Лента событий сделки --- */

.deal-timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 4px;
  border-left: 2px solid var(--accent);
}

.deal-timeline-item {
  position: relative;
  margin: 0 0 16px 14px;
  padding: 0;
}

.deal-timeline-item::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.deal-timeline-meta {
  font-size: 12px;
  color: var(--label-muted);
  margin-bottom: 4px;
}

.deal-timeline-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-heading);
}

.deal-timeline-detail {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

/* --- Диспетчеризация: недельный календарный вид --- */

.dispatch-view-toggle {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.dispatch-view-toggle .dispatch-view-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-tint-strong);
  color: var(--text);
}

.dispatch-week-banner {
  margin-bottom: 1rem;
}

.dispatch-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .dispatch-week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .dispatch-week-grid {
    grid-template-columns: 1fr;
  }
}

.dispatch-week-col {
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  background: var(--surface);
  min-height: 120px;
  overflow: hidden;
}

.dispatch-week-col-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--surface-raised);
  cursor: pointer;
  user-select: none;
}

.dispatch-week-col-head:hover {
  background: var(--hover-surface);
}

.dispatch-week-col-head.is-selected-day {
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.dispatch-week-dow {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-heading);
}

.dispatch-week-dm {
  font-size: 13px;
  color: var(--label-muted);
}

.dispatch-week-col-body {
  padding: 8px 10px 10px;
  font-size: 13px;
}

.dispatch-week-slot {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.dispatch-week-slot:last-child {
  border-bottom: none;
}

.dispatch-week-slot-time {
  flex-shrink: 0;
  width: 44px;
  font-variant-numeric: tabular-nums;
  color: var(--link);
}

.dispatch-week-slot-title {
  font-weight: 600;
  line-height: 1.35;
}

.dispatch-week-slot-meta {
  font-size: 12px;
  margin-top: 2px;
}

.dispatch-week-empty {
  margin: 4px 0;
  font-size: 13px;
}

.dispatch-section-hr {
  border: none;
  border-top: 1px solid var(--border-muted);
  margin: 1.25rem 0;
}

.dispatch-section-title {
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
}

/* --- Реестр КП: колонки --- */

.quotes-columns-toolbar {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-muted);
}

.quotes-columns-heading {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text-heading);
}

.quotes-columns-lead {
  margin: 0 0 12px;
  font-size: 13px;
  max-width: 52rem;
}

.quotes-columns-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.portal-profile-access-card {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(217, 0, 18, 0.32);
}

.quotes-col-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

@media (max-width: 640px) {
  .quotes-registry-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Профиль: матрица доступов --- */

.portal-access-scroll {
  overflow-x: auto;
  margin-top: 12px;
  -webkit-overflow-scrolling: touch;
}

.portal-access-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.portal-access-matrix th,
.portal-access-matrix td {
  border: 1px solid var(--border-muted);
  padding: 8px 10px;
  text-align: center;
}

.portal-access-matrix th[scope="row"] {
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.portal-access-matrix thead th {
  background: var(--surface-raised);
}

.portal-access-your-col {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.portal-access-your-row {
  background: rgba(217, 0, 18, 0.1);
}

.portal-access-cell {
  font-variant-numeric: tabular-nums;
}

/* Карточка сделки: три колонки */
.deal-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .deal-layout {
    grid-template-columns: 1fr;
  }
  .deal-widgets {
    order: 3;
  }
}

.deal-layout-sticky {
  position: sticky;
  top: 16px;
}

.deal-feed-card .deal-timeline {
  max-height: min(70vh, 720px);
  overflow-y: auto;
}

.deal-custom-fields .deal-cf-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 14px;
}

.deal-custom-fields .deal-cf-row span {
  color: var(--muted);
  font-size: 13px;
}

/* Канбан сделок */
.portal-kanban {
  padding: 12px;
  overflow: hidden;
}

.portal-kanban-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.portal-kanban-col {
  flex: 0 0 220px;
  min-width: 200px;
  background: var(--panel-bg);
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: min(75vh, 900px);
}

.portal-kanban-col-drag {
  outline: 2px dashed var(--accent);
}

.portal-kanban-col-virtual {
  border-style: dashed;
  opacity: 0.95;
}

.portal-kanban-col-head {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--surface);
  border-radius: 10px 10px 0 0;
}

.portal-kanban-col-body {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-kanban-card {
  background: var(--surface-deep);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.portal-kanban-card-title {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  text-decoration: none;
  color: var(--link);
}

.portal-kanban-card-meta {
  font-size: 12px;
  margin-bottom: 6px;
}

.portal-kanban-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.portal-kanban-preview {
  font-size: 12px;
  padding: 6px 8px;
}
