:root {
  --page: #f4f6f8;
  --panel: #ffffff;
  --ink: #1d252c;
  --muted: #62707c;
  --line: #d9e0e6;
  --blue: #1f6feb;
  --green: #198754;
  --amber: #b7791f;
  --red: #c2413b;
  --shadow: 0 12px 32px rgba(29, 37, 44, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 20px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.topbar p,
.panel h2,
.panel h3 {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
  font-weight: 700;
}

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

.shell {
  padding: 22px;
}

.summary {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.summary article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary article {
  min-height: 88px;
  padding: 18px;
}

.summary span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.summary strong {
  display: block;
  font-size: 30px;
  line-height: 1.25;
  margin-top: 8px;
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(290px, 360px) minmax(300px, 430px) minmax(360px, 1fr);
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-head,
.detail-head,
.small-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.panel h2 {
  font-size: 18px;
}

.panel h3 {
  font-size: 15px;
}

.filters,
form,
.action-grid,
.timeline,
.links-box {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 6px;
}

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

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

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

.primary {
  background: var(--blue);
  color: #ffffff;
}

.secondary {
  background: #e9f1ff;
  color: #184c9a;
}

.ghost {
  background: #edf1f5;
  color: var(--ink);
}

.danger {
  background: #fdecec;
  color: var(--red);
}

.wide {
  width: 100%;
}

.ticket-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  max-height: calc(100vh - 296px);
  overflow: auto;
  padding-right: 4px;
}

.ticket-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  color: inherit;
  display: grid;
  gap: 8px;
  padding: 12px;
  text-align: left;
  width: 100%;
}

.ticket-card.is-selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.ticket-card.done {
  border-left-color: var(--green);
}

.ticket-card.waiting {
  border-left-color: var(--amber);
}

.ticket-card.cancelled {
  border-left-color: var(--red);
}

.ticket-card strong {
  font-size: 15px;
  line-height: 1.25;
  white-space: normal;
}

.ticket-card small,
.description,
.empty-state p {
  color: var(--muted);
}

.meta-row,
.card-meta,
.linked-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.key {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 7px 9px;
}

.key {
  background: #eef4ff;
  color: var(--blue);
  margin-bottom: 8px;
}

.badge {
  background: #e8f6ee;
  color: var(--green);
}

.badge.neutral {
  background: #eef1f4;
  color: var(--muted);
}

.badge.warning {
  background: #fff5df;
  color: var(--amber);
}

.detail-head h2 {
  font-size: 22px;
  line-height: 1.2;
  margin: 0;
  overflow-wrap: anywhere;
}

.description {
  line-height: 1.5;
  margin: 16px 0;
  white-space: pre-wrap;
}

.time-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
  padding: 14px;
}

.time-box span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.time-box strong {
  display: block;
  font-size: 20px;
  margin-top: 5px;
}

.inline-control {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(160px, 1fr) auto;
}

.linked-ticket {
  background: #eef4ff;
  border-radius: 999px;
  color: #184c9a;
  padding: 7px 9px;
}

.timeline ol {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  border-left: 3px solid var(--line);
  padding-left: 12px;
}

.timeline time {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 26px;
}

.toast {
  background: var(--ink);
  border-radius: 6px;
  bottom: 18px;
  color: #ffffff;
  left: 50%;
  max-width: min(480px, calc(100vw - 28px));
  padding: 12px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 40;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar,
  .panel-head,
  .detail-head,
  .small-head {
    align-items: stretch;
    flex-direction: column;
  }

  .shell {
    padding: 14px;
  }

  .summary,
  .workspace,
  .field-grid,
  .action-grid,
  .time-box {
    grid-template-columns: 1fr;
  }

  .ticket-list {
    max-height: none;
  }

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