:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --soft: #e5ece9;
  --ink: #14201d;
  --muted: #61716d;
  --line: #d7dfdc;
  --primary: #176b63;
  --danger: #b42318;
  --ok: #207a3d;
  --warn: #a15c00;
  --shadow: 0 10px 24px rgba(20, 32, 29, 0.07);
}

* {
  box-sizing: border-box;
}

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

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

.app-header,
.tabs,
main {
  width: min(920px, calc(100% - 28px));
  margin-inline: auto;
}

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

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
  line-height: 1.12;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.language-select,
.network-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 7px 10px;
}

.network-status {
  min-width: 78px;
  text-align: center;
}

.network-status.is-online {
  color: var(--ok);
  border-color: rgba(32, 122, 61, 0.35);
}

.network-status.is-offline {
  color: var(--warn);
  border-color: rgba(161, 92, 0, 0.35);
}

.tabs {
  display: flex;
  gap: 8px;
  padding-bottom: 12px;
}

button,
.file-button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
}

.tab,
.secondary,
.secondary-file {
  background: var(--soft);
  color: var(--ink);
}

.tab.is-active {
  background: var(--primary);
  color: #fff;
}

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

main {
  padding-bottom: 46px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}

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

.type-dots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0 16px;
}

.type-dot {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 78px;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.type-dot span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary);
  font-size: 14px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.type-dot small {
  max-width: 84px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  word-break: keep-all;
}

.type-dot.is-active span {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.ticket-form,
.filters,
.detail-panel,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.ticket-form,
.result-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

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

label {
  display: grid;
  gap: 6px;
  color: #30423d;
  font-size: 14px;
  font-weight: 750;
}

.input-title {
  display: block;
  color: #30423d;
  font-size: 14px;
  font-weight: 750;
}

label.is-wide {
  grid-column: span 2;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

.language-select,
.network-status {
  width: auto;
}

.photo-input {
  display: grid;
  gap: 10px;
  border: 1px dashed #9aaba6;
  border-radius: 8px;
  padding: 12px;
}

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

.photo-actions,
.actions,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-actions input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}

figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

figure img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

figcaption {
  display: grid;
  gap: 6px;
  padding: 7px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.photo-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  min-height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 0 10px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 850;
}

.compact-stats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 10px;
  padding-bottom: 2px;
}

.compact-stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 9px;
  font-size: 12px;
}

.compact-stats strong {
  color: var(--ink);
  font-size: 14px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 170px 150px;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
}

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

.ticket-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.ticket-open {
  position: relative;
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 92px;
  padding: 12px 108px 12px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  text-align: left;
}

.ticket-open:hover {
  border-color: rgba(23, 107, 99, 0.5);
}

.ticket-open strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.ticket-open span,
.ticket-open small {
  color: var(--muted);
}

.ticket-type {
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
  color: var(--primary);
  background: #dff2ee;
}

.ticket-open .badge {
  position: absolute;
  top: 10px;
  right: 10px;
}

.row-delete {
  align-self: stretch;
  min-height: 42px;
  background: #f4e4e2;
  color: var(--danger);
  padding: 0 8px;
}

.badge.closed,
.badge.resolved {
  color: var(--ok);
  background: #e2f4e8;
}

.badge.waiting-parts {
  color: var(--warn);
  background: #fff2d9;
}

.badge.in-progress,
.badge.in-review {
  color: #1e4fb5;
  background: #e3ecff;
}

.detail-panel {
  min-height: 260px;
  padding: 16px;
}

.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-head h3 {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

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

.detail-grid div {
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

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

.list-empty {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.detail-panel h4 {
  margin-bottom: 10px;
}

.detail-actions {
  margin-top: 16px;
}

.detail-actions select,
.detail-actions input {
  width: min(220px, 100%);
}

@media (max-width: 640px) {
  .app-header {
    align-items: start;
  }

  .header-tools {
    flex-wrap: wrap;
    justify-content: end;
  }

  .language-select,
  .network-status {
    min-width: 92px;
    min-height: 34px;
    padding: 6px 8px;
  }

  .tabs {
    gap: 6px;
  }

  .tab {
    flex: 1;
    padding: 0 8px;
  }

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

  label.is-wide {
    grid-column: auto;
  }

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

  .ticket-row {
    position: relative;
    grid-template-columns: 1fr;
  }

  .ticket-open {
    padding-right: 76px;
  }

  .row-delete {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 13px;
    min-height: 32px;
    padding: 0 8px;
  }

  .ticket-open .badge {
    position: static;
    justify-self: start;
  }
}
