:root {
  --accent: #6a4c93;
  --accent-light: #9b7fc7;
  --bg: #f6f3fb;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --muted: #7a7a7a;
  --danger: #d64545;
  --ok: #3b9c5c;
  --warn: #d69b2b;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: var(--accent);
  color: white;
  padding: 1.2rem 1rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.2rem;
}

.form-card h2 {
  margin-top: 0;
  font-size: 1.1rem;
  color: var(--accent);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 0.4rem;
  color: var(--text);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.checkbox-label input {
  width: 1.3rem;
  height: 1.3rem;
}

input,
select,
textarea {
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid #d9d3e8;
  border-radius: 10px;
  background: #fbfaff;
  color: var(--text);
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(154, 127, 199, 0.25);
}

textarea {
  resize: vertical;
  font-family: inherit;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

button {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:active {
  transform: scale(0.97);
}

button.secondary {
  background: #e6e1f2;
  color: var(--accent);
}

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

.hidden {
  display: none !important;
}

/* Tabs */
.tabs {
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  padding: 0.6rem 1rem 0;
  gap: 0.4rem;
}

.tab-btn {
  flex: 1;
  background: #e6e1f2;
  color: var(--accent);
  border-radius: 10px 10px 0 0;
  padding: 0.7rem 0.5rem;
  font-size: 0.95rem;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
}

.tab-panel {
  display: none;
}

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

/* Entries table */
#list-tab {
  padding-top: 0.3rem;
}

.entries-table-wrapper {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  overflow-x: auto;
  margin-bottom: 1rem;
}

.entries-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.entries-table th,
.entries-table td {
  padding: 0.85rem 0.7rem;
  text-align: left;
  white-space: nowrap;
}

.entries-table thead th {
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
  position: sticky;
  top: 0;
}

.entries-table tbody tr.entry-row {
  border-top: 1px solid #eee6f7;
}

.entries-table tr.kunto-hyvin {
  background: rgba(59, 156, 92, 0.07);
}

.entries-table tr.kunto-ok {
  background: rgba(214, 155, 43, 0.08);
}

.entries-table tr.kunto-huonosti {
  background: rgba(214, 69, 69, 0.07);
}

.behaviour-pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  background: var(--accent-light);
}

.behaviour-pill.kunto-hyvin {
  background: var(--ok);
}

.behaviour-pill.kunto-ok {
  background: var(--warn);
}

.behaviour-pill.kunto-huonosti {
  background: var(--danger);
}

.entry-subrow td.col-extra {
  white-space: normal;
  word-break: break-word;
  padding-top: 0;
  padding-bottom: 0.85rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.col-actions {
  display: flex;
  gap: 0.3rem;
}

.icon-btn {
  flex: none;
  background: transparent;
  padding: 0.3rem 0.5rem;
  font-size: 1.1rem;
  line-height: 1;
}

.icon-btn:active {
  background: #f0ecf9;
}

@keyframes highlightFade {
  0% {
    background-color: #fff3b0;
  }
  100% {
    background-color: transparent;
  }
}

.highlight-new {
  animation: highlightFade 2.5s ease-out forwards;
}

.empty-msg {
  color: var(--muted);
  text-align: center;
  font-style: italic;
  padding: 1rem;
}

@media (min-width: 600px) {
  header h1 {
    font-size: 1.8rem;
  }
}
