:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #1d232f;
  --muted: #5b677a;
  --line: #d9e2ef;
  --accent: #0369a1;
  --good: #0f8f56;
  --bad: #c03434;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #eaf2fc 0%, #f8fbff 40%, #f4f7fb 100%);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: grid;
  gap: 14px;
}

h1, h2 {
  margin: 0 0 8px;
}

p {
  margin: 0;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

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

input, select, button {
  font: inherit;
}

input, select {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

button {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #0c83c7;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

button.secondary {
  border-color: #8aa8bf;
  background: #f2f8fc;
  color: #1d455d;
}

button.danger {
  border-color: #c96f6f;
  background: #fef1f1;
  color: #932d2d;
}

.actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.note {
  margin-top: 8px;
  font-size: 12px;
}

.stats {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfdff;
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
}

.stat .value {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: right;
  white-space: nowrap;
}

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(13), td:nth-child(13),
th:nth-child(14), td:nth-child(14) {
  text-align: left;
}

.good {
  color: var(--good);
}

.bad {
  color: var(--bad);
}

.tpsl-editor {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.tpsl-input {
  width: 95px;
  padding: 6px;
}

.close-preview {
  width: 100%;
  font-size: 12px;
  color: var(--muted);
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-badge {
  background: #e1effe;
  color: #1e429f;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

.auth-panel {
  background: linear-gradient(135deg, #ffffff 0%, #f9fbff 100%);
  border: 1px solid #c7d9ef;
  padding: 40px 20px;
  text-align: center;
}

.auth-container {
  max-width: 400px;
  margin: 0 auto;
}

.auth-box h2 {
  margin-bottom: 5px;
  color: var(--accent);
}

.auth-desc {
  font-size: 14px;
  margin-bottom: 20px;
}

.auth-grid {
  text-align: left;
  grid-template-columns: 1fr;
}

.auth-actions {
  justify-content: center;
  margin-top: 20px;
}

.primary-btn {
  background: var(--accent);
  color: white;
  padding: 12px 24px;
  border: none;
  font-weight: 600;
  flex: 1;
}

.requires-auth.is-locked {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.5) blur(1px);
}

.panel {
  transition: all 0.3s ease;
}

.panel.requires-auth.is-locked {
  display: none;
}

@media (max-width: 768px) {
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

  th, td {
    padding: 6px;
    font-size: 12px;
  }

  .tpsl-input {
    width: 82px;
  }

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