:root {
  --tp-accent: #a352f5;
  --tp-accent-dark: #7730bf;
  --tp-bg: #f7f5fb;
  --tp-text: #252238;
  --tp-muted: #6f6a7d;
  --tp-border: #e8e2ef;
  --tp-good: #18845b;
  --tp-warn: #a66a00;
  --tp-danger: #bd3341;
  --tp-touch: 48px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
.tp-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--tp-bg);
  color: var(--tp-text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  overflow-wrap: anywhere;
}
.tp-shell { width: calc(100% - 24px); margin: 0 auto; }
.tp-header { background: #fff; border-bottom: 1px solid var(--tp-border); }
.tp-header-inner { min-height: 64px; display: flex; align-items: center; }
.tp-brand { display: flex; align-items: center; gap: 10px; color: var(--tp-text); text-decoration: none; font-weight: 700; }
.tp-brand img { width: 122px; height: auto; }
.tp-brand span { padding-left: 10px; border-left: 1px solid var(--tp-border); color: var(--tp-muted); font-size: .78rem; }
.tp-nav {
  position: fixed;
  z-index: 50;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 64px;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--tp-border);
  box-shadow: 0 -7px 24px rgba(42,28,58,.08);
  backdrop-filter: blur(12px);
}
.tp-nav form { display: contents; margin: 0; }
.tp-nav a,
.tp-nav button {
  min-width: 0;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--tp-muted);
  font: inherit;
  font-size: .72rem;
  text-decoration: none;
  cursor: pointer;
}
.tp-nav i { font-size: 1.35rem; }
.tp-nav a:active,
.tp-nav button:active { background: #f3ebfc; color: var(--tp-accent-dark); }
.tp-main { min-height: calc(100dvh - 145px); padding: 22px 0 32px; }
.tp-authenticated .tp-main { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.tp-footer { padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--tp-border); background: #fff; color: var(--tp-muted); font-size: .8rem; line-height: 1.6; }
.tp-authenticated .tp-footer { display: none; }
.tp-footer a { color: inherit; }
.tp-auth-wrap { width: 100%; margin: 4px auto; }
.tp-card {
  min-width: 0;
  padding: 19px;
  background: #fff;
  border: 1px solid var(--tp-border);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(67,39,91,.055);
}
.tp-card + .tp-card { margin-top: 16px; }
.tp-card h1,
.tp-card h2,
.tp-card h3 { margin-top: 0; }
.tp-card h2 { font-size: 1.25rem; }
h1 { font-size: clamp(1.65rem, 8vw, 2.2rem); line-height: 1.12; }
.tp-eyebrow { color: var(--tp-accent-dark); font-weight: 750; font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; }
.tp-lead { color: var(--tp-muted); font-size: 1rem; line-height: 1.58; }
.tp-grid,
.tp-grid-3 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.tp-field { margin-bottom: 18px; }
.tp-field label { display: block; margin-bottom: 7px; font-weight: 680; }
.tp-field input,
.tp-field select,
.tp-field textarea {
  width: 100%;
  min-height: var(--tp-touch);
  padding: 12px 13px;
  border: 1px solid #bdb4c8;
  border-radius: 11px;
  background: #fff;
  color: var(--tp-text);
  font: inherit;
  font-size: 16px;
}
.tp-field input[type="checkbox"] { width: 24px; min-height: 24px; accent-color: var(--tp-accent); }
.tp-field input[type="file"] { min-height: 56px; padding: 10px; background: #fcfaff; }
.tp-field input[type="file"]::file-selector-button { min-height: 38px; margin-right: 10px; padding: 7px 12px; border: 0; border-radius: 8px; background: #eee2fb; color: var(--tp-accent-dark); font-weight: 700; }
.tp-field textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
.tp-field input:focus,
.tp-field select:focus,
.tp-field textarea:focus { outline: 3px solid rgba(163,82,245,.18); border-color: var(--tp-accent); }
.tp-hint { display: block; margin-top: 7px; color: var(--tp-muted); font-size: .84rem; line-height: 1.45; }
.tp-btn {
  width: 100%;
  min-height: var(--tp-touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  font: inherit;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.tp-btn:disabled { opacity: .65; cursor: wait; }
.tp-btn-primary { background: var(--tp-accent); color: #fff; }
.tp-btn-primary:hover { background: var(--tp-accent-dark); color: #fff; }
.tp-btn-secondary { background: #fff; border-color: var(--tp-border); color: var(--tp-text); }
.tp-btn-danger { background: #fff0f1; border-color: #f3c4c8; color: var(--tp-danger); }
.tp-alert { margin: 0 0 18px; padding: 13px 14px; border-radius: 11px; line-height: 1.5; }
.tp-alert-error { background: #fff0f1; color: #8d202d; border: 1px solid #f4c8cd; }
.tp-alert-success { background: #edf9f3; color: #106541; border: 1px solid #bee6d2; }
.tp-alert-info { background: #f3ebfc; color: #5f258d; border: 1px solid #dec9f2; }
.tp-meta { color: var(--tp-muted); font-size: .88rem; line-height: 1.45; }
.tp-stat { min-width: 0; padding: 15px; border: 1px solid var(--tp-border); border-radius: 12px; background: #fcfbfd; }
.tp-stat-label { margin-bottom: 5px; color: var(--tp-muted); font-size: .78rem; }
.tp-stat-value { font-size: 1.08rem; font-weight: 760; }
.tp-list { display: grid; gap: 11px; }
.tp-list-item { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-width: 0; padding: 15px; border: 1px solid var(--tp-border); border-radius: 12px; background: #fff; color: var(--tp-text); text-decoration: none; }
.tp-list-item:active { border-color: #ccb1e7; background: #fcf9ff; }
.tp-list-title { font-weight: 750; }
.tp-list-sub { margin-top: 5px; color: var(--tp-muted); font-size: .84rem; line-height: 1.4; }
.tp-badge { display: inline-flex; align-items: center; flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; font-size: .75rem; font-weight: 750; white-space: nowrap; }
.tp-badge-good { background: #e6f6ee; color: var(--tp-good); }
.tp-badge-warn { background: #fff3da; color: var(--tp-warn); }
.tp-badge-muted { background: #f0edf3; color: var(--tp-muted); }
.tp-badge-danger { background: #fff0f1; color: var(--tp-danger); }
.tp-section-head { display: flex; flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 17px; }
.tp-section-head h1,
.tp-section-head h2 { margin: 0; }
.tp-back-link { display: inline-flex; align-items: center; min-height: 44px; margin: -8px 0 2px; color: var(--tp-accent-dark); font-weight: 650; text-decoration: none; }
.tp-table-wrap { overflow: visible; border: 0; }
.tp-table { width: 100%; border-collapse: separate; border-spacing: 0 10px; background: transparent; }
.tp-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tp-table tbody,
.tp-table tr,
.tp-table td { display: block; width: 100%; }
.tp-table tr { padding: 8px 14px; border: 1px solid var(--tp-border); border-radius: 12px; background: #fff; }
.tp-table td { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid #f0ecf4; text-align: right; }
.tp-table td:last-child { border-bottom: 0; }
.tp-table td::before { content: attr(data-label); color: var(--tp-muted); font-size: .79rem; font-weight: 650; text-align: left; }
.tp-empty { padding: 28px 12px; color: var(--tp-muted); text-align: center; }
.tp-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.tp-divider { height: 1px; margin: 22px 0; background: var(--tp-border); }
.tp-description { white-space: pre-wrap; line-height: 1.62; }
.tp-attachments { display: grid; gap: 9px; }
.tp-attachment { min-height: 46px; display: flex; align-items: center; gap: 7px; padding: 10px 12px; border: 1px solid var(--tp-border); border-radius: 9px; color: var(--tp-text); font-size: .88rem; text-decoration: none; }
.tp-auth-links { display: grid; gap: 4px; margin-top: 17px; font-size: .9rem; }
.tp-auth-links a { min-height: 44px; display: flex; align-items: center; color: var(--tp-accent-dark); }
.tp-consent { display: grid !important; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; font-weight: 500 !important; line-height: 1.5; }
.tp-upload-box { padding: 14px; border: 1px dashed #baa5cf; border-radius: 12px; background: #fcf9ff; }
.tp-upload-box + .tp-upload-box { margin-top: 10px; }
.tp-upload-title { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-weight: 740; }
.tp-file-preview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.tp-file-preview:empty { display: none; }
.tp-file-preview-item { min-width: 0; padding: 7px; border: 1px solid var(--tp-border); border-radius: 9px; background: #fff; }
.tp-file-preview-item img { width: 100%; aspect-ratio: 1; display: block; border-radius: 6px; object-fit: cover; }
.tp-file-preview-name { margin-top: 5px; overflow: hidden; color: var(--tp-muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.tp-submit-note { display: none; margin-top: 9px; color: var(--tp-muted); font-size: .82rem; text-align: center; }
.tp-form-submitting .tp-submit-note { display: block; }

@media (min-width: 520px) {
  .tp-shell { width: min(100% - 40px, 1120px); }
  .tp-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tp-actions { grid-template-columns: repeat(2, minmax(0, max-content)); }
  .tp-btn { width: auto; }
  .tp-auth-links { display: flex; justify-content: space-between; }
  .tp-list-item { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 18px; }
}

@media (min-width: 760px) {
  .tp-header-inner { min-height: 72px; justify-content: space-between; gap: 24px; }
  .tp-brand img { width: 142px; }
  .tp-brand span { font-size: .88rem; }
  .tp-nav { position: static; display: flex; min-height: auto; padding: 0; border: 0; box-shadow: none; background: transparent; backdrop-filter: none; }
  .tp-nav form { display: block; }
  .tp-nav a,
  .tp-nav button { min-height: 44px; flex-direction: row; gap: 6px; padding: 9px 12px; font-size: .9rem; }
  .tp-nav i { font-size: 1rem; }
  .tp-nav a:hover,
  .tp-nav button:hover { background: #f3ebfc; color: var(--tp-accent-dark); }
  .tp-main { padding: 40px 0 64px; }
  .tp-authenticated .tp-main { padding-bottom: 64px; }
  .tp-footer,
  .tp-authenticated .tp-footer { display: block; padding: 20px 0; border-top: 1px solid var(--tp-border); background: #fff; color: var(--tp-muted); font-size: .85rem; }
  .tp-footer a { color: inherit; }
  .tp-auth-wrap { width: min(500px, 100%); margin: 28px auto; }
  .tp-card { padding: 28px; }
  .tp-card + .tp-card { margin-top: 20px; }
  .tp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .tp-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .tp-section-head { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
  .tp-table-wrap { overflow: auto; border: 1px solid var(--tp-border); border-radius: 13px; }
  .tp-table { border-collapse: collapse; border-spacing: 0; background: #fff; }
  .tp-table thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .tp-table tbody { display: table-row-group; }
  .tp-table tr { display: table-row; padding: 0; border: 0; border-radius: 0; background: transparent; }
  .tp-table th,
  .tp-table td { display: table-cell; width: auto; padding: 13px 15px; border-bottom: 1px solid var(--tp-border); text-align: left; white-space: nowrap; }
  .tp-table th { color: var(--tp-muted); background: #fbfafd; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
  .tp-table td::before { display: none; }
  .tp-table tr:last-child td { border-bottom: 0; }
  .tp-attachments { display: flex; flex-wrap: wrap; }
  .tp-file-preview { grid-template-columns: repeat(5, minmax(0, 110px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
