:root {
  --purple: #7b4fa5;
  --purple-dark: #5e3b81;
  --purple-light: #efe6f7;
  --border: #d9cdea;
  --text: #2c2233;
  --bg: #f7f5fa;
  --ok: #2e7d32;
  --error: #c62828;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--purple);
  color: white;
  padding: 14px 24px;
}
.brand-mark { font-weight: 800; font-size: 20px; margin-right: 12px; }
.brand-sub { font-size: 14px; opacity: 0.9; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: white;
  border-bottom: 2px solid var(--border);
  padding: 0 16px;
}
.tab-btn {
  border: none;
  background: none;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--purple-dark);
  border-bottom: 3px solid transparent;
}
.tab-btn.active {
  border-bottom: 3px solid var(--purple);
  font-weight: 600;
}

main { padding: 20px 24px 60px; max-width: 1100px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

h2 { color: var(--purple-dark); margin-top: 0; }
h3 { color: var(--purple-dark); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.grid-6 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }

.field { margin-bottom: 12px; display: flex; flex-direction: column; }
.field label { font-size: 13px; margin-bottom: 4px; color: #55495f; }
.field label small { color: #8a7c99; font-weight: normal; }

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  background: white;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--purple);
}

.field-btn { justify-content: flex-end; }

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 4px;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary {
  background: var(--purple);
  color: white;
  margin-top: 10px;
}
.btn-primary:hover { background: var(--purple-dark); }
.btn-secondary {
  background: var(--purple-light);
  color: var(--purple-dark);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e3d4f2; }

.rows-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}
.rows-table th, .rows-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}
.rows-table th { background: var(--purple-light); color: var(--purple-dark); }
.rows-table input, .rows-table select { width: 100%; padding: 4px 6px; font-size: 13px; }

.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }

.msg { margin-top: 12px; font-size: 14px; }
.msg.ok { color: var(--ok); }
.msg.error { color: var(--error); }

.hidden { display: none !important; }
.hint { color: #7a6d88; font-size: 13px; }

.ticket-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.ticket-card h3 { margin-top: 0; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 20px; font-size: 13px; }
.kv div span { color: #7a6d88; }

.log-entry {
  border-left: 3px solid var(--purple);
  padding: 6px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  background: white;
}
.log-entry .meta { color: #8a7c99; font-size: 12px; }

.badge {
  display: inline-block;
  background: var(--purple-light);
  color: var(--purple-dark);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 800px) {
  .grid-2, .grid-6 { grid-template-columns: 1fr; }
}
