/* ===== sec.cint19.ru design system =====================================
   Follows the visual identity of the parent site (cint19.ru): Montserrat
   type, CINT blue / grey / orange palette — executed with more care
   (proper scale, depth, motion) than the Bitrix original. Shared across
   every page; add new components here rather than inline in templates. */

@font-face {
  font-family: "Montserrat";
  font-weight: 400;
  src: url("../fonts/Montserrat-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Montserrat";
  font-weight: 500;
  src: url("../fonts/Montserrat-Medium.ttf") format("truetype");
}
@font-face {
  font-family: "Montserrat";
  font-weight: 600;
  src: url("../fonts/Montserrat-SemiBold.ttf") format("truetype");
}
@font-face {
  font-family: "Montserrat";
  font-weight: 700;
  src: url("../fonts/Montserrat-Bold.ttf") format("truetype");
}

:root {
  /* Brand palette — matches cint19.ru's own CSS variables verbatim */
  --brand-dark: #333333;
  --brand-dark-2: #4f4f4f;
  --brand-blue: #005a9f;
  --brand-blue-dark: #00457a;
  --brand-orange: #e76238;
  --brand-success: #007400;
  --brand-danger: #d10000;

  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #e7eff1;
  --surface-soft-2: #d0e1ed;
  --border: #dde3e8;

  --text: #333333;
  --text-muted: #6b7280;
  --text-faint: #9aa1ab;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-md: 0 8px 28px rgba(51, 51, 51, 0.1);
  --shadow-lg: 0 20px 50px rgba(51, 51, 51, 0.14);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font-sans: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--surface-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ===== Layout ========================================================== */

.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  text-align: center;
}

.card-header {
  background: var(--brand-dark);
  padding: var(--space-5) var(--space-6) var(--space-4);
}

.card-body {
  padding: var(--space-6);
}

/* ===== Brand mark ======================================================= */

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 36px;
  height: 39px;
  flex-shrink: 0;
}
.brand-mark svg {
  width: 100%;
  height: 100%;
  fill: #ffffff;
}

.brand-word {
  text-align: left;
  color: #ffffff;
  font-size: 9.5px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.92;
}

.brand-sub {
  margin-top: var(--space-2);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

/* ===== Typography ======================================================= */

.title {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2);
}

.subtitle {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0 0 var(--space-5);
}

.text-muted {
  color: var(--text-muted);
}

/* ===== Buttons =========================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--brand-blue);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 90, 159, 0.28);
}
.btn-primary:hover {
  background: var(--brand-blue-dark);
}

.btn-ghost {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-soft-2);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* ===== Form fields ======================================================= */

.field-label {
  display: block;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 var(--space-2);
}

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s var(--ease);
}
.input:focus {
  outline: none;
  border-color: var(--brand-blue);
}

/* ===== Section heading (left-aligned, inside a centered card) =========== */

.section-title {
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 var(--space-3);
}

/* ===== Software list ===================================================== */

.software-list {
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
  text-align: left;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.software-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 10px 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
.software-list li:last-child {
  border-bottom: none;
}

.tag {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text-muted);
}
.tag-success { background: #e6f4e6; color: var(--brand-success); }
.tag-warning { background: #fdf0e7; color: var(--brand-orange); }
.tag-danger  { background: #fbe6e6; color: var(--brand-danger); }

/* ===== Machines table ===================================================== */

.machine-list {
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
  text-align: left;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.machine-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.machine-list li:last-child {
  border-bottom: none;
}
.machine-name {
  font-size: 0.88rem;
  font-weight: 600;
}
.machine-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* ===== QR panel ========================================================== */

.qr-panel {
  display: inline-block;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin: var(--space-2) 0 var(--space-5);
  line-height: 0;
}
.qr-panel img {
  display: block;
  width: 220px;
  height: 220px;
}

/* ===== Status line (pending / success / error) ========================== */

.status-line {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.88rem;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-orange);
  flex-shrink: 0;
  animation: pulse 1.4s ease-in-out infinite;
}
.status-line.is-success .status-dot {
  background: var(--brand-success);
  animation: none;
}
.status-line.is-error .status-dot {
  background: var(--brand-danger);
  animation: none;
}
.status-line.is-success {
  color: var(--brand-success);
  background: #e6f4e6;
}
.status-line.is-error {
  color: var(--brand-danger);
  background: #fbe6e6;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

/* ===== Avatar ============================================================ */

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  font-size: 1.4rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--brand-blue);
}

/* ===== Misc =============================================================== */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: var(--space-5) 0;
}

.footnote {
  margin-top: var(--space-5);
  font-size: 0.78rem;
  color: var(--text-faint);
}

.footnote a {
  color: var(--text-faint);
  text-decoration: underline;
}

/* ===== Styled <select> ==================================================== */
/* Native selects ignore most styling — appearance:none + a custom chevron
   drawn via background-image is the standard way around that. */

.select-wrap {
  position: relative;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
select.input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  background: var(--surface);
  cursor: pointer;
}

/* ===== App shell (everything after login) ================================ */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--brand-dark);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space-5);
  height: 64px;
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.app-brand-mark {
  width: 26px;
  height: 28px;
  flex-shrink: 0;
}
.app-brand-mark svg {
  width: 100%;
  height: 100%;
  fill: #ffffff;
}
.app-brand-text {
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
}
.app-brand-text small {
  display: block;
  font-size: 0.68rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
}

.app-nav {
  display: flex;
  gap: var(--space-2);
  flex: 1;
}
.app-nav-link {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.app-nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}
.app-nav-link.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

.app-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.app-user-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius-pill);
  transition: background-color 0.15s var(--ease);
}
.app-user-link:hover {
  background: rgba(255, 255, 255, 0.08);
}
.app-user-link.is-active {
  background: rgba(255, 255, 255, 0.14);
}
.app-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-blue);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.app-user-name {
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-logout {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 6px 8px;
}
.app-logout:hover {
  color: #ffffff;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.page-head .title {
  margin: 0;
}
.page-head .subtitle {
  margin: var(--space-1) 0 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-5);
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5) var(--space-6);
  text-align: left;
}

/* ===== Profile-completion modal =========================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  z-index: 100;
}
.modal-backdrop[hidden] {
  display: none;
}
.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover {
  background: var(--surface-soft-2);
  color: var(--text);
}

.is-clickable-row {
  cursor: pointer;
}

@media (max-width: 720px) {
  .app-header-inner { gap: var(--space-3); padding: 0 var(--space-3); }
  .app-brand-text { display: none; }
  .app-user-name { display: none; }
  .app-main { padding: var(--space-5) var(--space-3) var(--space-6); }
}

/* ===== Copy field ========================================================= */

.copy-field {
  display: flex;
  gap: var(--space-2);
}
.copy-field .input {
  flex: 1;
  min-width: 0;
}
.btn-copy {
  flex-shrink: 0;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s var(--ease);
}
.btn-copy:hover {
  background: var(--surface-soft-2);
}
.btn-copy.is-copied {
  background: #e6f4e6;
  color: var(--brand-success);
  border-color: transparent;
}

/* ===== Searchable combobox ================================================ */

.combobox {
  position: relative;
}
.combobox-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}
.combobox-item {
  padding: 10px 14px;
  font-size: 0.88rem;
  cursor: pointer;
}
.combobox-item:hover {
  background: var(--surface-soft);
}

/* ===== Section utilities (search box + count, list scroll) =============== */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.section-count {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-weight: 500;
}
.filter-input {
  margin-bottom: var(--space-3);
}
.scroll-list {
  max-height: 360px;
  overflow-y: auto;
}

/* ===== Tabs (in-content navigation, distinct from the header nav) ======= */

.tabs {
  display: flex;
  gap: var(--space-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
}
.tab-link {
  padding: 0 0 12px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.tab-link:hover {
  color: var(--text);
}
.tab-link.is-active {
  color: var(--brand-blue);
  border-bottom-color: var(--brand-blue);
}

/* ===== Filter bar ========================================================= */

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.filter-bar .field {
  min-width: 180px;
  flex: 1;
}
.filter-bar .field-narrow {
  min-width: 140px;
  flex: 0 0 auto;
}
.filter-bar .input {
  margin: 0;
}
.filter-bar .btn {
  width: auto;
  flex-shrink: 0;
}

/* ===== Data table ========================================================= */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover {
  background: var(--surface-soft);
}
.data-table .cell-muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}
.data-table .empty-row td {
  text-align: center;
  color: var(--text-faint);
  padding: var(--space-6);
}

/* ===== Pagination ========================================================= */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.pagination-links {
  display: flex;
  gap: var(--space-2);
}
.pagination-links a,
.pagination-links span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text);
}
.pagination-links a:hover {
  background: var(--surface-soft);
}
.pagination-links .is-current {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #fff;
}
.pagination-links .is-disabled {
  color: var(--text-faint);
  border-color: var(--border);
  opacity: 0.5;
}

/* ===== Chip list (compact manual-entry tags) ============================= */

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text);
  cursor: default;
}
