body {
  background: #f6f8fb;
  color: #171717;
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0; padding: 0;
}

header {
  display: flex;
  align-items: center;
  background: #fff;
  padding: 18px 8vw;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 6px #0001;
}

main {
  max-width: 900px;
  margin: 2rem auto;
  padding: 1.2rem;
}

.card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 18px #0002;
  margin-bottom: 24px;
  padding: 1.3em 2em;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.row {
  display: flex;
  gap: 10px;
}

label {
  font-weight: 500;
}
input, select, button, textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d0d7df;
  margin-top: 6px;
  margin-bottom: 6px;
  box-sizing: border-box;
}

/* === Buttons (element + utility class) === */
button, .button, .btn {
  background: #3b82f6;
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, filter .15s, opacity .15s;
  display: inline-block;
}
button:hover, .button:hover, .btn:hover { background: #2563eb; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Variants used in admin UI */
.btn-primary   { background:#1164a4; }
.btn-secondary { background:#e1e1e1; color:#222; }
.btn-info      { background:#2980b9; }
.btn-danger    { background:#c0392b; }
.btn-success   { background:#27ae60; }
.btn-warning   { background:#f39c12; }
.btn-secondary:hover { filter: brightness(.95); }

/* Chips / tags */
.chip{
  display:inline-block;
  background:#eef2f7;
  border-radius:10px;
  padding:2px 8px;
  margin:2px 4px 2px 0;
  font-size:.85em;
  color:#156085;
}

.badge {
  padding: 3px 10px;
  border-radius: 15px;
  font-size: 0.85em;
  margin-left: 8px;
  background: #e0e7ef;
  color: #333;
}
.badge.ok { background: #bbf7d0; color: #15803d; }
.badge.bad { background: #fecaca; color: #b91c1c; }

/* KPI tiles on dashboard */
.kpi-tile{
  flex: 1 1 180px;
  background:#fff;
  border:1px solid #e4e8ee;
  border-radius: 12px;
  box-shadow:0 1px 4px rgba(0,0,0,.03);
  padding:12px 14px;
  min-width:180px;
}
.kpi-label{ color:#6b7a8f; font-size:.9em; }
.kpi-value{ font-size:1.6em; font-weight:700; margin-top:4px; }

@media (max-width: 600px) {
  main { padding: 1vw; }
  .card { padding: 1em 0.7em; }
  header { padding: 1em 2vw; }
}
.table-container { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}
th, td {
  padding: 10px 7px;
  text-align: left;
}
th {
  background: #f1f5fa;
  font-weight: bold;
  border-bottom: 1.5px solid #d0d7df;
}
tr:nth-child(even) td { background: #f9fafb; }

/* ---- MODAALIT ---- */
.modal {
  position: fixed;
  left: 0; top: 0; right: 0; bottom: 0;
  background: #0006;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  visibility: hidden;
  opacity: 0;
  transition: all 0.17s;
}
.modal.show { visibility: visible; opacity: 1; }
.modal-content {
  background: #fff;
  padding: 2em 1.2em 1.5em;
  border-radius: 14px;
  max-width: 95vw;
  width: 370px;
  box-shadow: 0 8px 32px #0002;
  position: relative;
  transition: transform 0.13s cubic-bezier(.77,0,.18,1.01);
  max-height: 80vh;
  overflow-y: auto;
}
.modal.show .modal-content { transform: scale(1.04); }
.close-btn {
  background: none; border: none; color: #555; font-size: 1.4em;
  position: absolute; top: 10px; right: 14px; cursor: pointer;
}
.hidden { display: none !important; }

#memberModal .modal-content { max-width: 430px; width: 98vw; }
/* Pienet button-tyylit modalissa */
#memberModal .btn { width: auto; margin: 0 5px 7px 0; }

/* Tabs (WhatsApp/Historia/Audit/Kuukaudet) */
#memberTabs { user-select:none; }
#memberTabs .tabnav-item{
  background:#f3f5f8;
  border:1px solid #e4e8ee;
  color:#156085;
}
#memberTabs .tabnav-item.active{
  background:#dfeaf4;
  border-color:#cfe0ee;
}

/* WhatsApp thread box */
#waThread{
  border:1px solid #e4e8ee;
  border-radius:10px;
  padding:10px;
  max-height:250px;
  overflow:auto;
  background:#fafbfc;
  scrollbar-width: thin;
}
#waThread::-webkit-scrollbar{ width: 8px; height: 8px; }
#waThread::-webkit-scrollbar-thumb{ background:#cbd5e1; border-radius:8px; }

/* Responsiivinen jäsenkortti */
@media (max-width: 700px) {
  .member-card table, .member-card thead, .member-card tbody, .member-card th, .member-card td, .member-card tr {
    display: block; width: 100%;
  }
  .member-card thead { display: none; }
  .member-card tr {
    margin-bottom: 0.7em; border-bottom: 1px solid #eee;
  }
  .member-card td {
    padding: 6px 0; text-align: left; border: none; font-size: 1.05em;
  }
  .member-card td:before {
    content: attr(data-label) ": ";
    font-weight: bold; display: inline-block; min-width: 90px; color: #333;
  }
}

/* Helpers */
.muted { color:#6b7a8f; }

/* Täysruutuinen modal sisäsivulla */
.modal-content.modal-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  padding: 16px 18px 20px;
}
#applicationsRoot table td .subtle {
  color: #6b7280;
  font-size: 0.92em;
}
#applicationsRoot .pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .8em;
}
.pill.pending  { background:#fff7e6; color:#b26b00; }
.pill.approved { background:#eaf9f0; color:#15803d; }
.pill.rejected { background:#fdecee; color:#b91c1c; }

