:root {
  --brand: #0060ae;
  --brand-bright: #00aeef;
  --accent-orange: #f97316;
  --accent-orange-bright: #fb923c;
  --brand-cool: #008dcc;
  --brand-teal: #54a491;
  --ink: #101828;
  --muted: #667085;
  --line: #d9e2ec;
  --panel: #ffffff;
  --panel-soft: #f7fbff;
  --page: #eef6fb;
  --danger: #d7263d;
  --success: #178c4f;
  --warning: #d18800;
  --shadow: 0 20px 60px rgba(16, 24, 40, 0.12);
  --toast-bg: #101828;
  --radius: 8px;
}

[data-theme="dark"] {
  --ink: #f6f8fb;
  --muted: #aab6c5;
  --line: #253246;
  --panel: #111827;
  --panel-soft: #0b1220;
  --page: #050914;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  --toast-bg: #0060ae;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-view {
  --brand: #f97316;
  --brand-bright: #fb923c;
  --page: #edf4f7;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(249, 115, 22, 0.22) 0%, rgba(249, 115, 22, 0.08) 31%, transparent 58%),
    linear-gradient(315deg, rgba(0, 141, 204, 0.24) 0%, rgba(84, 164, 145, 0.10) 34%, transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.18)),
    var(--page);
  background-attachment: fixed;
}

[data-theme="dark"] .login-view {
  --page: #050914;
  background:
    linear-gradient(135deg, rgba(249, 115, 22, 0.20) 0%, rgba(249, 115, 22, 0.08) 34%, transparent 62%),
    linear-gradient(315deg, rgba(0, 141, 204, 0.22) 0%, rgba(84, 164, 145, 0.10) 36%, transparent 64%),
    linear-gradient(180deg, rgba(5, 9, 20, 0.40), rgba(5, 9, 20, 0.92)),
    var(--page);
}

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

.brand-lockup,
.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-bright));
  border-radius: 6px;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-mark span {
  transform: translateY(-1px);
}

.brand-logo {
  width: 46px;
  height: 54px;
  object-fit: contain;
  flex: 0 0 auto;
  transition: width 260ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease, visibility 220ms ease;
}

.sidebar-logo {
  width: 34px;
  height: 50px;
}

.brand-subline,
.brand-block .sidebar-label span {
  color: var(--accent-orange);
  font-size: 0.82rem;
  font-weight: 700;
  background: repeating-linear-gradient(90deg, var(--accent-orange) 0%, var(--accent-orange-bright) 25%, #fff 50%, var(--accent-orange-bright) 75%, var(--accent-orange) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  transition: filter 180ms ease;
}

.brand-subline:hover,
.brand-block .sidebar-label span:hover {
  color: transparent;
  animation: brandShine 1800ms linear infinite;
  filter: drop-shadow(0 0 8px rgba(249, 115, 22, 0.24));
}

@keyframes brandShine {
  0% { background-position: 200% center; }
  100% { background-position: 0% center; }
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.1;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.02rem;
}

.stack {
  display: grid;
  gap: 14px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--panel);
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(0, 174, 239, 0.28);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover,
.nav-item:hover,
.ticket-card:hover,
.project-card:hover,
.customer-button:hover,
.doc-button:hover,
.mini-counter:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.1);
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.danger-button:active,
.icon-button:active,
.nav-item:active,
.ticket-card:active,
.project-card:active,
.customer-button:active,
.doc-button:active,
.mini-counter:active {
  transform: translateY(0) scale(0.99);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

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

.primary-button:hover {
  background: #004f91;
}

.secondary-button {
  color: var(--brand);
  background: rgba(0, 174, 239, 0.08);
  border-color: rgba(0, 96, 174, 0.22);
}

.ghost-button {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

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

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
  display: inline-grid;
  place-items: center;
}

.icon-button > span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.icon-button > .icon,
.icon-button > span > .icon,
.nav-item > span:first-child > .icon {
  margin: auto;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  transition: grid-template-columns 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 84px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: padding 280ms cubic-bezier(0.22, 1, 0.36, 1);
  contain: layout paint;
}

.sidebar .brand-block {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 42px;
  align-items: center;
  width: 100%;
}

.sidebar-toggle {
  margin-left: 0;
  justify-self: end;
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.mobile-theme-toggle {
  display: none;
}

.sidebar-toggle .icon {
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app-shell.sidebar-collapsed .sidebar-toggle .icon {
  transform: rotate(180deg);
}

.app-shell.sidebar-collapsed .sidebar {
  padding-inline: 18px;
}

.app-shell.sidebar-collapsed .sidebar-label,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .user-card,
.app-shell.sidebar-collapsed #profileButton,
.app-shell.sidebar-collapsed #logoutButton {
  display: none;
  max-width: 0;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateX(-8px);
  overflow: hidden;
}

.app-shell.sidebar-collapsed .brand-block,
.app-shell.sidebar-collapsed .sidebar-actions {
  justify-content: center;
}

.app-shell.sidebar-collapsed .brand-block {
  display: grid;
  grid-template-columns: 42px;
  justify-items: center;
  justify-content: center;
  gap: 0;
  min-height: 48px;
}

.app-shell.sidebar-collapsed .nav-item {
  width: 48px;
  height: 48px;
  justify-content: center;
  padding: 0;
}

.app-shell.sidebar-collapsed .nav-list {
  justify-items: center;
}

.app-shell.sidebar-collapsed .sidebar-actions {
  width: 100%;
}

.app-shell.sidebar-collapsed .sidebar .brand-mark,
.app-shell.sidebar-collapsed .sidebar .brand-logo {
  width: 0;
  opacity: 0;
  visibility: hidden;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  margin: 0 auto;
  justify-self: center;
}

.brand-block strong {
  display: block;
  margin-bottom: 2px;
}

.sidebar-label,
.nav-label,
.user-card,
#profileButton,
#logoutButton {
  max-width: 230px;
  max-height: 160px;
  transition: opacity 220ms ease, transform 260ms cubic-bezier(0.22, 1, 0.36, 1), max-width 260ms cubic-bezier(0.22, 1, 0.36, 1), max-height 260ms cubic-bezier(0.22, 1, 0.36, 1), visibility 260ms ease;
}

.nav-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
  font-weight: 800;
}

.nav-item > span:first-child {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.app-shell.sidebar-collapsed .nav-item {
  grid-template-columns: 1fr;
  place-items: center;
}

.app-shell.sidebar-collapsed .nav-item > span:first-child {
  width: 48px;
  height: 48px;
}

.nav-item:hover,
.nav-item.active {
  color: var(--brand);
  background: rgba(0, 174, 239, 0.08);
  border-color: rgba(0, 96, 174, 0.16);
}

.sidebar-footer {
  display: grid;
  gap: 12px;
}

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

.user-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.user-card-button {
  width: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.main {
  min-width: 0;
  padding: 24px;
}

.customer-portal {
  min-height: 100vh;
  background: var(--page);
}

.customer-portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.customer-portal-header h1 {
  margin: 0;
}

.customer-portal-main {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

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

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

.topbar-actions select {
  min-width: 230px;
}

.view {
  display: grid;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.stat-card,
.panel,
.ticket-card,
.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.05);
}

.stat-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 14px;
  overflow: visible;
}

.stat-button,
.mini-counter {
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line);
}

.stat-button {
  appearance: none;
}

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

.mini-counter {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.stat-card .stat-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  overflow: visible;
}

.stat-card strong {
  font-size: 1.7rem;
}

.stat-card small {
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 16px;
}

.department-grid,
.integration-grid,
.doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.department-row,
.integration-card,
.doc-card,
.customer-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--panel-soft);
}

.department-row {
  display: grid;
  gap: 10px;
}

.department-heading,
.ticket-heading,
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-titlebar {
  margin-bottom: 14px;
}

.dept-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--brand);
}

.dept-firewall .dept-dot,
.badge.dept-firewall,
.employee-badge.dept-firewall,
.member-choice.dept-firewall,
select option.dept-firewall {
  background: #0060ae;
  color: #fff;
}

.dept-software .dept-dot,
.badge.dept-software,
.employee-badge.dept-software,
.member-choice.dept-software,
select option.dept-software {
  background: #008dcc;
  color: #fff;
}

.dept-media .dept-dot,
.badge.dept-media,
.employee-badge.dept-media,
.member-choice.dept-media,
select option.dept-media {
  background: #54a491;
  border: 0;
  color: #fff;
}

select option[class^="dept-"],
select option[class*=" dept-"] {
  margin-block: 2px;
  padding: 8px 12px;
  border: 2px solid transparent;
  font-size: 0.88rem;
}

select option[class^="dept-"]:checked,
select option[class*=" dept-"]:checked,
select option[class^="dept-"]:hover,
select option[class*=" dept-"]:hover {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75);
}

.bar {
  height: 8px;
  overflow: hidden;
  background: rgba(102, 112, 133, 0.16);
  border-radius: 999px;
}

.bar progress {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  appearance: none;
  background: transparent;
}

.bar progress::-webkit-progress-bar {
  background: transparent;
}

.bar progress::-webkit-progress-value {
  background: var(--brand-bright);
}

.bar progress::-moz-progress-bar {
  background: var(--brand-bright);
}

.ticket-tools,
.filters,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ticket-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.75fr);
  gap: 16px;
}

.ticket-list {
  display: grid;
  gap: 12px;
  max-height: min(66vh, 760px);
  overflow: auto;
  padding-right: 4px;
}

.ticket-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  width: 100%;
}

.ticket-card.is-selected {
  border-color: var(--brand-bright);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.16);
}

.ticket-heading h3 {
  margin: 0;
}

.ticket-meta,
.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ticket-meta {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.8fr) minmax(160px, 0.8fr);
  gap: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.ticket-meta span {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 14px;
  margin-right: 14px;
  border-right: 1px solid var(--line);
}

.ticket-meta span:last-child {
  border-right: 0;
  margin-right: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
  flex: 0 0 auto;
}

.badge.status-open {
  background: var(--brand);
}

.badge.status-assigned {
  background: #4f46e5;
}

.badge.status-accepted {
  background: #0891b2;
}

.badge.status-in_progress {
  background: var(--warning);
}

.badge.status-waiting_customer {
  background: #7c3aed;
}

.badge.status-done {
  background: var(--success);
}

.badge.status-rejected {
  background: var(--danger);
}

.type-badge {
  background: #475467;
}

.badge.urgency-low {
  background: #64748b;
}

.badge.urgency-medium {
  background: var(--brand-bright);
}

.badge.urgency-high {
  background: var(--warning);
}

.badge.urgency-critical {
  background: var(--danger);
}

.detail-empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}

.history-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.history-item p {
  margin-bottom: 4px;
}

.history-item small,
.muted {
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 9, 20, 0.58);
  animation: modalBackdropIn 160ms ease both;
}

.modal-panel {
  width: min(100%, 760px);
  max-height: min(92vh, 900px);
  overflow: auto;
  padding: 18px;
  animation: modalPanelIn 190ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal-backdrop.is-closing {
  animation: modalBackdropOut 180ms ease both;
}

.modal-backdrop.is-closing .modal-panel {
  animation: modalPanelOut 180ms ease both;
}

@keyframes modalBackdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalBackdropOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes modalPanelIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalPanelOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

.modal-wide {
  width: min(100%, 1040px);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: 360px;
  padding: 12px 14px;
  color: #fff;
  background: var(--toast-bg);
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-weight: 800;
  opacity: 0;
  pointer-events: auto;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.toast.hiding {
  opacity: 0;
  transform: translateY(10px);
  transition-duration: 520ms;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.customer-list {
  display: grid;
  gap: 10px;
  max-height: min(66vh, 760px);
  overflow: auto;
  padding-right: 4px;
}

.customer-button,
.doc-button {
  width: 100%;
  color: var(--ink);
  text-align: left;
}

.checkbox-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.centered-checkbox {
  align-self: end;
  justify-content: center;
  min-height: 42px;
}

.ticket-detail-grid {
  align-items: end;
}

.ticket-detail-grid .maintenance-field,
.ticket-detail-grid .invoice-field,
.ticket-detail-grid .employee-field,
.form-grid .maintenance-field,
.form-grid .invoice-field,
.form-grid .employee-field {
  min-height: 67px;
}

.ticket-detail-grid .invoice-field,
.form-grid .invoice-field {
  align-self: start;
  min-height: 67px;
  padding: 25px 12px 0;
}

.ticket-detail-grid .maintenance-field,
.form-grid .maintenance-field,
.ticket-detail-grid .employee-field,
.form-grid .employee-field {
  align-self: start;
}

.ticket-detail-grid .employee-field {
  grid-column: span 2;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

.panel-soft-section {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

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

.zip-city-grid {
  grid-template-columns: minmax(120px, 0.38fr) minmax(240px, 1fr);
}

.customer-portal-access-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.service-level-section {
  padding: 0;
}

.service-level-details {
  padding: 12px;
}

.service-level-details summary {
  display: grid;
  grid-template-columns: minmax(130px, 0.5fr) minmax(220px, 1fr);
  align-items: end;
  gap: 12px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
  list-style: none;
  position: relative;
  padding-right: 28px;
}

.service-level-details summary::-webkit-details-marker {
  display: none;
}

.service-level-details summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 2px;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: translateY(-65%) rotate(45deg);
  transition: transform 160ms ease;
}

.service-level-details[open] summary::after {
  transform: translateY(-35%) rotate(225deg);
}

.service-level-select {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.service-level-select span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.service-level-select select {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

.service-level-grid {
  margin-top: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.code-block {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 420px;
  padding: 12px;
  color: var(--ink);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.doc-preview {
  max-height: 62vh;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.doc-preview h2,
.doc-preview h3,
.doc-preview h4 {
  margin: 18px 0 8px;
}

.doc-preview h2:first-child,
.doc-preview h3:first-child {
  margin-top: 0;
}

.doc-preview p,
.doc-preview li {
  line-height: 1.55;
}

.doc-table-line {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.doc-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 12px 0 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.doc-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

.doc-table th {
  color: var(--brand);
  background: var(--panel-soft);
  font-weight: 800;
}

.doc-table td:last-child,
.doc-table th:last-child {
  border-right: 0;
}

.doc-table tbody tr:last-child td {
  border-bottom: 0;
}

.icon {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex: 0 0 auto;
  overflow: visible;
}

.nowrap {
  white-space: nowrap;
}

.login-submit {
  width: 100%;
}

.dashboard-ticket-panel .ticket-list {
  margin-top: 6px;
}

.detail-section {
  margin-top: 18px;
}

.todo-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 12px;
}

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

.todo-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.todo-item p {
  margin-bottom: 2px;
}

.todo-item.is-done p {
  color: var(--muted);
  text-decoration: line-through;
}

.todo-check {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: transform 140ms ease, border-color 140ms ease, color 140ms ease;
}

.todo-check:hover {
  color: var(--brand-bright);
  border-color: var(--brand-bright);
  transform: translateY(-1px);
}

.todo-check:disabled {
  cursor: default;
  opacity: 0.7;
  transform: none;
}

.todo-delete {
  justify-self: end;
}

.change-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.worklog-grid {
  grid-template-columns: minmax(270px, 1.1fr) minmax(150px, 0.6fr) minmax(220px, 1.4fr);
  align-items: end;
}

.time-capture-field {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.time-capture-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.maintenance-plan {
  margin-top: -2px;
}

.maintenance-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide-field {
  grid-column: span 2;
}

.field-hint {
  margin: 2px 0 0;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
}

.project-list {
  display: grid;
  gap: 12px;
  max-height: min(66vh, 760px);
  overflow: auto;
  padding-right: 4px;
}

.project-card {
  width: 100%;
  display: grid;
  gap: 12px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.project-card h3 {
  margin-bottom: 4px;
}

.project-tree ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.project-detail {
  display: grid;
  gap: 14px;
}

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

.project-ticket-list {
  margin-top: 12px;
}

.assigned-members,
.member-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.assigned-members {
  margin-top: 4px;
}

.employee-badge,
.member-choice {
  color: #fff;
  border-radius: 7px;
  font-weight: 800;
}

.employee-badge {
  display: inline-block;
  width: min(100%, 560px);
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.82rem;
  max-width: 100%;
}

.employee-badge small,
.member-choice small {
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.employee-badge strong,
.member-choice strong {
  white-space: nowrap;
}

.tag-separator {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.45);
}

.member-checkbox-grid {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.member-checkbox-grid legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.member-choice {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: min(100%, 560px);
  min-height: 38px;
  padding: 7px 9px;
  cursor: pointer;
  max-width: 100%;
  border: 2px solid transparent;
}

.member-choice:hover,
.member-choice.active,
.member-choice:focus-visible {
  border-color: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.22);
}

.member-choice input {
  width: 16px;
  min-height: 16px;
}

.member-choice-text {
  display: grid;
  grid-template-columns: 150px auto 170px auto 130px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.password-input-field {
  grid-column: 1 / -1;
}

.password-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px auto;
  align-items: center;
  gap: 8px;
}

.employee-picker {
  display: grid;
  gap: 6px;
}

.employee-picker > span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.employee-picker-list {
  display: grid;
  gap: 7px;
  max-height: 244px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.employee-option {
  width: 100%;
  text-align: left;
}

.employee-option:not([class*="dept-"]) {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

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

.worklog-draft {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.worklog-draft strong,
.worklog-draft small,
.worklog-draft p {
  display: block;
  margin: 0;
}

.worklog-draft small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.worklog-draft p {
  margin-top: 4px;
  color: var(--muted);
}

.phase-add-form,
.task-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin: 10px 0 14px;
}

.phase-list {
  display: grid;
  gap: 12px;
}

.phase-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.phase-form textarea {
  min-height: 84px;
}

.compact-actions {
  justify-content: start;
}

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

.task-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}

.task-check {
  min-height: 42px;
  justify-content: center;
}

.task-done-row input[name="title"] {
  color: var(--muted);
  text-decoration: line-through;
}

.task-done {
  color: var(--muted);
  text-decoration: line-through;
}

.panel-soft-section {
  margin-top: 2px;
}

.equal-actions > button,
.equal-actions > a {
  min-width: 170px;
}

.inline-search {
  width: min(100%, 360px);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.inline-search input {
  min-width: 0;
}

.search-select {
  gap: 6px;
}

.select-search {
  min-height: 34px;
}

.reset-confirm {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.system-footnote {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 4px 2px;
}

.system-footnote span:not(:last-child)::after {
  content: "";
}

.user-admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.65fr) minmax(0, 1.35fr);
  gap: 16px;
}

.role-presets-panel {
  grid-column: 1 / -1;
}

.role-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.role-checkboxes .checkbox-row {
  min-height: 32px;
}

.user-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-stats {
  margin-top: 12px;
}

.top-actions {
  justify-content: start;
  margin-top: 0;
  margin-bottom: 12px;
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-grid,
  .ticket-layout,
  .user-admin-grid {
    grid-template-columns: 1fr;
  }

  .role-presets-panel {
    grid-column: auto;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-block {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 10px;
    width: 100%;
  }

  .mobile-theme-toggle {
    display: inline-flex;
  }

  .sidebar-toggle {
    margin-left: 0;
  }

  .app-shell:not(.sidebar-collapsed) .sidebar-toggle .icon {
    transform: rotate(90deg);
  }

  .app-shell.sidebar-collapsed .sidebar {
    padding: 10px 14px;
    gap: 0;
  }

  .app-shell.sidebar-collapsed .brand-block {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    min-height: 42px;
    gap: 8px;
    justify-items: stretch;
  }

  .app-shell.sidebar-collapsed .nav-list,
  .app-shell.sidebar-collapsed .sidebar-footer,
  .app-shell.sidebar-collapsed .sidebar-label {
    display: none;
  }

  .app-shell.sidebar-collapsed .nav-label,
  .app-shell.sidebar-collapsed .user-card span,
  .app-shell.sidebar-collapsed .user-card strong {
    display: block;
  }

  .app-shell.sidebar-collapsed .sidebar .brand-mark {
    display: grid;
  }

  .app-shell.sidebar-collapsed .sidebar .brand-logo {
    display: block;
    width: 34px;
    height: 38px;
    opacity: 1;
    visibility: visible;
  }

  .app-shell.sidebar-collapsed .sidebar-toggle .icon {
    transform: rotate(0deg);
  }

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

  .sidebar-footer,
  .user-card,
  .sidebar-actions {
    width: 100%;
  }

  .sidebar-actions .icon-button {
    flex: 1 1 0;
  }

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

  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions select {
    min-width: 0;
  }

  .ticket-tools,
  .filters,
  .form-grid,
  .customer-field-grid,
  .zip-city-grid,
  .customer-portal-access-grid,
  .service-level-grid,
  .project-form-grid,
  .todo-add-form,
  .phase-add-form,
  .task-add-form,
  .worklog-grid,
  .department-grid,
  .integration-grid,
  .doc-grid {
    grid-template-columns: 1fr;
  }

  .service-level-details summary,
  .task-row {
    grid-template-columns: 1fr;
  }

  .employee-badge,
  .member-choice-text {
    grid-template-columns: minmax(110px, 1fr) auto minmax(120px, 1fr) auto minmax(90px, 0.8fr);
  }

  .ticket-detail-grid .employee-field {
    grid-column: auto;
  }

  .password-control {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .password-control .secondary-button {
    grid-column: 1 / -1;
  }

  .wide-field {
    grid-column: auto;
  }

  .ticket-meta {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .ticket-meta span {
    border-right: 0;
    margin-right: 0;
    padding-right: 0;
  }
}

@media (max-width: 560px) {
  .main,
  .sidebar {
    padding: 16px;
  }

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

  .nav-list {
    grid-template-columns: 1fr;
  }

  .department-heading,
  .ticket-heading,
  .row-between {
    align-items: start;
    flex-direction: column;
  }
}
