:root {
  --bg: #fff8f1;
  --panel: #ffffff;
  --line: #f1d5b8;
  --text: #2d2117;
  --muted: #8a6d55;
  --accent: #f97316;
  --accent-soft: #ffedd5;
  --danger: #b63131;
  --sidebar: #fff3e6;
  --sidebar-muted: #8a6d55;
  --radius: 10px;
  --shadow: 0 12px 24px rgba(171, 104, 49, 0.08);
}

html {
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: 10px;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 20%, #ffe8cf 0%, transparent 34%),
    radial-gradient(circle at 85% 10%, #fff3e1 0%, transparent 30%),
    var(--bg);
}

.global-topbar {
  height: 42px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff5e9 0%, #fff 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  position: sticky;
  top: 0;
  z-index: 60;
}

.global-topbar-left,
.global-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.global-breadcrumbs {
  font-size: 0.74rem;
  color: #8a6d55;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.global-breadcrumbs .crumb-link {
  color: #8a6d55;
  text-decoration: none;
  border-bottom: 1px dashed #e2b17f;
}

.global-breadcrumbs .crumb-btn {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.global-breadcrumbs .crumb-link:hover {
  color: #8b3d05;
}

.global-breadcrumbs .crumb-current {
  color: #6d3f18;
  font-weight: 700;
}

.global-breadcrumbs .crumb-sep {
  opacity: 0.6;
}

.global-login-label {
  font-size: 0.74rem;
  color: #8a6d55;
  font-weight: 700;
  white-space: nowrap;
}

.global-topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #7a4519;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
}

.global-topbar-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.global-topbar-btn:hover {
  border-color: #efc49c;
  background: #fff9f2;
}

.global-logout-btn {
  width: 32px;
  min-width: 32px;
  padding: 0;
}

.global-logout-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.global-datetime,
.global-user {
  font-size: 0.76rem;
  color: #744522;
  font-weight: 700;
  white-space: nowrap;
}

.global-user {
  text-decoration: none;
  border-bottom: 1px dashed #d38b49;
}

.global-user:hover {
  color: #8b3d05;
}

.field-counter-wrap {
  position: relative;
  width: 100%;
}

.field-counter {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 0.64rem;
  line-height: 1;
  color: #8a6d55;
  background: rgba(255, 255, 255, 0.86);
  padding: 1px 3px;
  border-radius: 4px;
  pointer-events: none;
}

.phone-field-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 6px;
  align-items: stretch;
  width: 100%;
}

.phone-field-wrap > * {
  min-width: 0;
  width: 100%;
}

.phone-prefix {
  min-width: 0;
  max-width: none;
  width: 100%;
}

.app-shell {
  min-height: calc(100vh - 42px);
  display: grid;
  grid-template-columns: 210px 1fr;
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 56px 1fr;
}

.sidebar {
  background: linear-gradient(170deg, #fff3e6 0%, #fff8f2 65%, #ffffff 100%);
  color: var(--text);
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sidebar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

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

.sidebar-brand-logo {
  width: auto;
  max-width: 100%;
  max-height: 36px;
  height: auto;
  object-fit: contain;
  display: block;
}

.brand-text {
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-weight: 800;
  background: linear-gradient(140deg, var(--accent), #fb923c);
  color: #fff;
}

.brand p {
  margin: 2px 0 0;
  color: var(--sidebar-muted);
  font-size: 0.82rem;
}

.sidebar-toggle {
  border: 0;
  border-radius: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  background: #fff4ea;
  color: #8a4f22;
  font-weight: 700;
  cursor: pointer;
}

.menu {
  display: grid;
  gap: 8px;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  justify-content: flex-start;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #4f3a28;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: all 140ms ease;
}

.menu-item:hover {
  transform: translateX(2px);
}

.menu-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}

.menu-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  opacity: 0.85;
}

.menu-item.active,
.menu-item:hover {
  color: #8b3d05;
  border: 1px solid #f8c79c;
}

.main {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.topbar {
  background: var(--panel);
  border: 1px solid #f0d3b6;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 9px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.12rem;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #8b3d05;
  font-weight: 700;
  white-space: nowrap;
}

.kpi-grid {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
}

.kpi-card p {
  margin: 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #f97316;
  display: inline-block;
}

.kpi-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.panel-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 6px;
  margin-bottom: 9px;
}

.panel-head h2 {
  margin: 0;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
  line-height: 1.3;
  max-width: 320px;
}

.form-grid,
.filter-grid,
.ticket-controls {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  min-width: 0;
}

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

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text);
  background: #fff;
  width: 100%;
  min-width: 0;
  min-height: 34px;
  line-height: 1.2;
}

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238a6d55' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
  padding-right: 28px;
}

.has-field-counter {
  padding-right: 52px;
}

textarea.has-field-counter {
  padding-bottom: 22px;
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.24);
}

button:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(249, 115, 22, 0.32);
}

.sidebar-toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.full-row {
  grid-column: 1 / -1;
}

#createForm.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.legacy-ticket-form {
  border: 1px solid #f0d7bf;
  background: linear-gradient(180deg, #fffaf5 0%, #fff4e8 100%);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  gap: 0;
  box-shadow: 0 10px 24px rgba(171, 104, 49, 0.08);
}

.legacy-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: #f2dcc3;
}

.legacy-box {
  display: grid;
  grid-template-columns: 110px 1fr;
  background: #fff8f1;
  min-height: 74px;
}

.legacy-box-label,
.legacy-row-label {
  background: #ffe8cf;
  color: #6d3f18;
  padding: 8px 8px;
  font-weight: 700;
  font-size: 0.84rem;
  border-right: 1px solid #f2d7bb;
}

.legacy-box-body {
  padding: 8px;
  display: grid;
  gap: 6px;
}

.legacy-info-line {
  font-size: 0.75rem;
  color: #8a6d55;
}

.legacy-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  border-top: 1px solid #f2dcc3;
  background: #fff8f1;
}

.legacy-row-content {
  padding: 7px;
  display: grid;
  gap: 7px;
}

.legacy-inline-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.legacy-inline-3 {
  grid-template-columns: 2fr 1fr 90px;
}

.legacy-inline-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.legacy-ticket-form input,
.legacy-ticket-form select,
.legacy-ticket-form textarea {
  border: 1px solid #eec9a8;
  border-radius: 8px;
  background: #fff;
  min-height: 32px;
}

.legacy-ticket-form input[type='radio'],
.legacy-ticket-form input[type='checkbox'] {
  width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  margin: 0;
  accent-color: #f97316;
}

.legacy-ticket-form textarea {
  min-height: 92px;
}

.legacy-radios {
  align-items: center;
}

.legacy-radios label,
.legacy-checkline {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: #6d3f18;
  white-space: nowrap;
}

.legacy-ticket-form button[type='submit'] {
  justify-self: start;
  min-width: 170px;
}

.ticket-list {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr;
}

.load-more-btn {
  margin-top: 10px;
  min-width: 170px;
}

.kanban-board {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  align-items: start;
}

.kanban-col {
  background: #f7faff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  min-height: 180px;
  display: grid;
  gap: 8px;
}

.kanban-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.kanban-col-head h3 {
  margin: 0;
  font-size: 0.82rem;
}

.kanban-count {
  background: #e6eef8;
  color: #2a4a67;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
}

.kanban-col-body {
  display: grid;
  gap: 8px;
}

.kanban-empty {
  color: var(--muted);
  font-size: 0.76rem;
  margin: 0;
}

.ticket-card {
  border: 1px solid var(--line);
  border-left: 4px solid #1d7f67;
  border-radius: 9px;
  padding: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.ticket-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(26, 58, 92, 0.1);
}

.ticket-card header {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
}

.ticket-head-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ticket-title {
  margin: 0;
  font-size: 0.92rem;
}

.ticket-id {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.72rem;
}

.status-badge,
.priority-badge {
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-new {
  background: #e8f2ff;
  color: #1d4f89;
}

.status-in_progress {
  background: #fff6dd;
  color: #7a5a0a;
}

.status-waiting_customer {
  background: #ffe9f0;
  color: #90385a;
}

.status-resolved {
  background: #e4f9ee;
  color: #166340;
}

.status-closed {
  background: #eceff4;
  color: #485361;
}

.priority-low {
  background: #edf7ff;
  color: #2a5d7f;
}

.priority-medium {
  background: #eef3ff;
  color: #3a4d8c;
}

.priority-high {
  background: #fff2e5;
  color: #8a5520;
}

.priority-urgent {
  background: #ffe7e7;
  color: #8e2a2a;
}

.ticket-meta {
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.ticket-description {
  margin-top: 0;
}

.note-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.notes-list {
  margin: 6px 0 0;
  padding-left: 14px;
  color: var(--muted);
}

.tag-urgent {
  color: var(--danger);
  font-weight: 700;
}

.empty {
  color: var(--muted);
  margin: 0;
}

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .menu-label {
  display: none;
}

.app-shell.sidebar-collapsed .menu-item {
  text-align: center;
  padding: 7px 0;
}

@media (max-width: 1000px) {
  .global-topbar {
    height: auto;
    padding: 6px 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .global-topbar-left,
  .global-topbar-right {
    justify-content: space-between;
  }

  .global-breadcrumbs {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 16px;
  }

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

  .panel-head {
    grid-template-columns: 1fr;
  }

  .panel-head span {
    text-align: left;
    max-width: none;
  }

  #createForm.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .legacy-top-grid {
    grid-template-columns: 1fr;
  }

  .legacy-inline-4 {
    grid-template-columns: 1fr 1fr;
  }

  .kanban-board {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .kanban-board {
    grid-template-columns: 1fr;
  }

  #createForm.form-grid {
    grid-template-columns: 1fr;
  }

  .legacy-box,
  .legacy-row {
    grid-template-columns: 1fr;
  }

  .legacy-inline-2,
  .legacy-inline-3,
  .legacy-inline-4 {
    grid-template-columns: 1fr;
  }
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-role {
  background: #e8effb;
  color: #2a4572;
}

.client-main {
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 42px);
}

.profile-page {
  min-height: 100vh;
}

.profile-main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.profile-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
}

.profile-form-vertical {
  grid-template-columns: 1fr;
  max-width: 560px;
}

.profile-form-grid label {
  display: grid;
  gap: 4px;
  font-weight: 700;
  color: #714627;
}

.profile-form-grid label.full-row {
  grid-column: 1 / -1;
}

.profile-form-grid input,
.profile-form-grid select {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 1px solid #e9c7a5;
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  color: #5b3a21;
  background: #fff;
}

.profile-more-row {
  margin-top: 10px;
}

@media (max-width: 1000px) {
  .profile-form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .profile-form-grid {
    grid-template-columns: 1fr;
  }
}

.bug-report-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
}

.bug-report-fab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(120deg, var(--accent), #ff7d1a);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 9px 14px;
  box-shadow: 0 10px 24px rgba(255, 120, 18, 0.25);
  cursor: pointer;
}

.bug-report-fab:hover {
  filter: brightness(1.03);
}

.bug-report-fab-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bug-report-fab-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.bug-report-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 16, 10, 0.34);
  z-index: 1300;
  padding: 14px;
}

.bug-report-modal.is-open {
  display: flex;
}

.bug-report-modal-card {
  width: min(560px, 96vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 42px rgba(45, 21, 3, 0.2);
  padding: 14px;
}

.bug-report-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.bug-report-modal-head h3 {
  margin: 0;
  font-size: 1rem;
}

.bug-report-form {
  display: grid;
  gap: 10px;
}

.bug-report-form label {
  display: grid;
  gap: 5px;
  font-size: 0.84rem;
  color: var(--muted);
}

.bug-report-form select,
.bug-report-form input,
.bug-report-form textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 10px;
  font-size: 0.84rem;
  color: var(--text);
}

.bug-report-form textarea {
  min-height: 90px;
  resize: vertical;
}

.bug-report-form-path {
  font-size: 0.76rem;
  color: var(--muted);
  word-break: break-word;
}

.bug-report-files {
  font-size: 0.74rem;
  color: var(--muted);
  word-break: break-word;
}

.bug-report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
