:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --line: #d9e2ef;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #d9f4ef;
  --danger: #c2410c;
  --danger-dark: #9a3412;
  --warning: #a16207;
  --success: #15803d;
  --shadow: 0 20px 55px rgba(15, 23, 42, 0.11);
  --shadow-strong: 0 22px 70px rgba(15, 23, 42, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.09), transparent 32%),
    linear-gradient(315deg, rgba(37, 99, 235, 0.08), transparent 28%),
    var(--bg);
  overflow-x: hidden;
}

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

.app-shell {
  width: min(1760px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 40px;
  animation: pageEnter 0.55s ease both;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 18px;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  max-width: 680px;
  font-size: clamp(30px, 3.8vw, 48px);
}

h2 {
  font-size: 22px;
}

.lead {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.hero-status {
  display: flex;
  align-items: center;
  min-width: 280px;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
  animation: floatIn 0.65s 0.08s ease both;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 6px rgba(15, 118, 110, 0.12);
  animation: statusPulse 1.9s ease-in-out infinite;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(460px, 0.82fr) minmax(720px, 1.18fr);
  gap: 30px;
  align-items: start;
}

.panel {
  border: 1px solid rgba(217, 226, 239, 0.9);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: panelRise 0.5s ease both;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.panel:hover {
  border-color: rgba(15, 118, 110, 0.28);
  box-shadow: var(--shadow-strong);
  transform: translateY(-2px);
}

.composer {
  padding: 28px 34px 30px;
}

.status-panel {
  overflow: hidden;
  min-height: 360px;
}

.status-panel .panel-header {
  margin: 0;
  padding: 28px 28px 22px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.template-tools {
  display: grid;
  grid-template-columns: minmax(170px, 0.95fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.field-group {
  min-width: 0;
}

label {
  display: block;
  margin: 16px 0 8px;
  color: #26364f;
  font-size: 15px;
  font-weight: 800;
}

.template-tools label {
  margin-top: 0;
  font-size: 12px;
  text-transform: uppercase;
}

input[type="text"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input[type="text"] {
  min-height: 46px;
  padding: 12px 14px;
}

select {
  min-height: 46px;
  padding: 11px 38px 11px 13px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #64748b 50%) calc(100% - 18px)
      calc(50% - 3px) / 6px 6px no-repeat,
    linear-gradient(135deg, #64748b 50%, transparent 50%) calc(100% - 13px)
      calc(50% - 3px) / 6px 6px no-repeat,
    var(--surface-soft);
  cursor: pointer;
}

textarea {
  min-height: 128px;
  padding: 13px 14px;
  line-height: 1.55;
  resize: vertical;
}

#dataInput {
  min-height: 150px;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #e8eef7;
  color: #334155;
  font-size: 0.92em;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
  position: relative;
  overflow: hidden;
}

button::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(255, 255, 255, 0.22) 45%,
    transparent 70%
  );
  content: "";
  transform: translateX(-120%);
}

button:hover::after {
  animation: buttonShine 0.7s ease;
}

button:hover {
  background: var(--primary-dark);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  box-shadow: none;
}

button.secondary {
  background: #1d4ed8;
}

button.secondary:hover {
  background: #1e40af;
  box-shadow: 0 10px 22px rgba(29, 78, 216, 0.2);
}

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

button.danger:hover {
  background: var(--danger-dark);
  box-shadow: 0 10px 22px rgba(194, 65, 12, 0.2);
}

button.ghost {
  min-height: 36px;
  padding: 8px 12px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

button.ghost:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: none;
}

button.compact {
  min-height: 46px;
  padding: 10px 14px;
}

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

.status {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
}

.status.success {
  color: var(--success);
}

.status.error {
  color: #b91c1c;
}

.status.warning {
  color: var(--warning);
}

.status.info {
  color: #1d4ed8;
}

.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: grid;
  width: min(360px, calc(100vw - 28px));
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: start;
  gap: 12px;
  position: relative;
  overflow: hidden;
  padding: 14px 14px 16px;
  border: 1px solid rgba(217, 226, 239, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
  pointer-events: auto;
  transform-origin: right top;
  animation: toastIn 0.34s cubic-bezier(0.2, 0.85, 0.2, 1.2) both;
  backdrop-filter: blur(14px);
}

.toast::before {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: #1d4ed8;
  content: "";
  animation: toastTimer 3.6s linear forwards;
}

.toast.success::before {
  background: var(--success);
}

.toast.error::before {
  background: #b91c1c;
  animation-duration: 5.2s;
}

.toast.warning::before {
  background: var(--warning);
}

.toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(29, 78, 216, 0.1);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
}

.toast.success .toast-icon {
  background: rgba(21, 128, 61, 0.12);
  color: var(--success);
}

.toast.error .toast-icon {
  background: rgba(185, 28, 28, 0.12);
  color: #b91c1c;
}

.toast.warning .toast-icon {
  background: rgba(161, 98, 7, 0.13);
  color: var(--warning);
}

.toast-content {
  display: grid;
  gap: 3px;
}

.toast-content strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
}

.toast-content span {
  color: #475569;
}

.toast-close {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.toast-close:hover {
  background: #eef2f7;
  color: var(--text);
  box-shadow: none;
}

.toast.is-leaving {
  animation: toastOut 0.22s ease forwards;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

th:nth-child(1),
td:nth-child(1) {
  width: 13%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 25%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 33%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 17%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 12%;
}

tbody tr {
  background: #ffffff;
}

tbody tr:nth-child(even) {
  background: #fbfdff;
}

tbody tr:hover {
  background: #f6fbfa;
}

tbody tr {
  animation: rowEnter 0.28s ease both;
}

td:nth-child(3) {
  white-space: normal;
  word-break: break-word;
}

td:nth-child(4) {
  white-space: normal;
  word-break: break-word;
}

td:nth-child(5) {
  font-weight: 800;
  text-transform: capitalize;
}

.empty-state {
  padding: 34px 16px;
  color: var(--muted);
  text-align: center;
}

textarea::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

textarea::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: #edf2f7;
}

textarea::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #bac7d6;
}

@media (max-width: 1280px) {
  .app-shell {
    width: min(1180px, calc(100% - 32px));
  }

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

  .status-panel {
    min-height: 0;
  }
}

@media (max-width: 980px) {
  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-status {
    min-width: 0;
  }

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

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

  .template-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 12px 0 18px;
  }

  .hero {
    gap: 14px;
    padding: 10px 0 16px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.05;
  }

  h2 {
    font-size: 19px;
  }

  .lead {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.55;
  }

  .eyebrow {
    font-size: 11px;
  }

  .hero-status {
    width: 100%;
    min-height: 48px;
    padding: 12px 13px;
    font-size: 13px;
  }

  .composer {
    padding: 16px;
  }

  .panel {
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.1);
  }

  .panel:hover {
    transform: none;
  }

  .status-panel .panel-header {
    gap: 12px;
    padding: 18px 18px 0;
  }

  .badge {
    width: fit-content;
  }

  label {
    margin-top: 15px;
    font-size: 14px;
  }

  input[type="text"] {
    min-height: 44px;
    padding: 11px 12px;
    font-size: 14px;
  }

  select {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
    font-size: 14px;
  }

  textarea {
    min-height: 118px;
    padding: 11px 12px;
    font-size: 14px;
  }

  #dataInput {
    min-height: 138px;
  }

  .hint {
    font-size: 12px;
  }

  .buttons {
    gap: 9px;
    margin-top: 17px;
  }

  .template-tools {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .template-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .panel-header,
  .buttons {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
    min-height: 45px;
    padding: 11px 14px;
  }

  .toast-close {
    width: 30px;
    min-height: 30px;
  }

  .status {
    padding: 10px 12px;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 13px;
  }

  .table-wrap {
    padding: 0 16px 16px;
    overflow: visible;
  }

  table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  th:nth-child(1),
  td:nth-child(1),
  th:nth-child(2),
  td:nth-child(2),
  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(5),
  td:nth-child(5) {
    width: 100%;
  }

  tbody tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
    overflow: hidden;
  }

  tbody tr.empty-row,
  tbody tr:has(.empty-state) {
    border-style: dashed;
    background: #fbfdff;
    box-shadow: none;
  }

  tbody tr:nth-child(even),
  tbody tr:hover {
    background: #ffffff;
  }

  td {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 12px;
    padding: 11px 12px;
    border-bottom: 1px solid #edf2f7;
    font-size: 13px;
    overflow-wrap: anywhere;
    word-break: normal;
    white-space: normal;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
  }

  td:nth-child(3) {
    max-width: none;
  }

  td:nth-child(4) {
    max-width: none;
  }

  .empty-state {
    display: block;
    width: 100%;
    min-height: 112px;
    padding: 34px 22px;
    border-bottom: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    overflow-wrap: normal;
    word-break: normal;
    white-space: normal;
  }

  .empty-state::before {
    content: "";
  }

  .toast-container {
    top: 10px;
    right: 10px;
    width: calc(100vw - 20px);
  }

  .toast {
    grid-template-columns: 32px 1fr auto;
    padding: 12px;
    font-size: 13px;
  }

  .toast-icon {
    width: 32px;
    height: 32px;
  }
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panelRise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes statusPulse {
  0%,
  100% {
    box-shadow: 0 0 0 5px rgba(15, 118, 110, 0.12);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(15, 118, 110, 0.05);
  }
}

@keyframes buttonShine {
  to {
    transform: translateX(120%);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(26px) translateY(-12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(20px) translateY(-8px) scale(0.96);
  }
}

@keyframes toastTimer {
  from {
    transform: scaleX(1);
    transform-origin: left;
  }

  to {
    transform: scaleX(0);
    transform-origin: left;
  }
}

@keyframes rowEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
