* { box-sizing: border-box; }

:root {
  --brand:#14b8a6;       /* teal */
  --brand-dark:#0d9488;  /* darker teal */
  --bg:#f9fafb;          /* very light gray */
  --card:#ffffff;
  --text:#1f2937;        /* slate gray */
  --muted:#6b7280;       /* muted gray */
  --border:#e5e7eb;      /* light border */
  --ok:#22c55e;          /* green success */
  --danger:#ef4444;      /* red */
}

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

/* Main Container */
.container {
  max-width: 920px;
  margin: 20px auto;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
  padding: 16px 16px 24px;
}

/* Top bar */
.topbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
}
.top-actions {
  display:flex;
  gap:8px;
  flex-wrap: wrap;
}

/* Typography */
h1,h2 {
  margin:10px 0 12px;
}
.section-title {
  display:flex;
  align-items:center;
  justify-content:space-between;
}

/* Group row */
.group-bar {
  display:grid;
  grid-template-columns: 80px 1fr;
  gap:12px;
  align-items:center;
  margin:8px 0 12px;
}
.group-controls {
  display:flex;
  gap:8px;
  flex-wrap: wrap;
}
.label {
  color:var(--muted);
  font-weight:600;
}

/* Inputs & selects */
select, .input {
  width:100%;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  outline:none;
  background:#f9fafb;
}
select:focus, .input:focus {
  border-color:var(--brand);
  box-shadow: 0 0 0 3px rgba(20,184,166,0.2);
}

/* Stack of chips */
.stack {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:10px;
}
.chip {
  display:flex;
  align-items:center;
  gap:6px;
  background:#ecfeff;
  border-radius:999px;
  padding:6px 10px;
  font-size:0.9rem;
}
.chip .x {
  background:#fee2e2;
  border:none;
  border-radius:999px;
  padding:4px 8px;
  cursor:pointer;
}
.chip .x:hover { background:#fecaca; }

/* Row layouts */
.row {
  display:flex;
  gap:8px;
}

/* Buttons */
.btn {
  padding:8px 10px;
  border:none;
  border-radius:8px;
  background:#f1f5f9;
  cursor:pointer;
  font-weight:600;
  font-size:0.9rem;
  transition: background 0.2s, transform 0.1s;
}
.btn:hover { background:#e2e8f0; }
.btn:active { transform: scale(0.97); }
.btn.ghost { background:#f9fafb; }
.btn.danger { background:#fee2e2; color:var(--danger); }
.btn.danger:hover { background:#fecaca; }
.btn.calc {
  background:var(--brand);
  color:#fff;
  width:100%;
  margin:6px 0 10px;
}
.btn.calc:hover { background:var(--brand-dark); }

/* Table */
.table-wrap {
  overflow:auto;
  border:1px solid var(--border);
  border-radius:12px;
}
.table {
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}
.table th, .table td {
  padding:8px;
  border-bottom:1px solid var(--border);
  font-size:0.9rem;
}
.table thead th {
  position:sticky;
  top:0;
  background:#f1f5f9;
  z-index:1;
}
.table tr:last-child td { border-bottom:none; }
.table input, .table select {
  width:100%;
  padding:6px 8px;
  border:1px solid var(--border);
  border-radius:8px;
  font-size:0.9rem;
  background:#f9fafb;
}
.table .del {
  background:#fee2e2;
  border:none;
  border-radius:8px;
  padding:6px;
  cursor:pointer;
}
.table .del:hover { background:#fecaca; }

/* Results */
.results {
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:42px;
}
.result-card {
  background:#ecfeff;
  padding:8px 10px;
  border-radius:10px;
  border-left:5px solid var(--brand);
  word-break:break-word;
}
.result-card.success {
  background:#dcfce7;
  border-left-color: var(--ok);
}

/* Share row */
.share-row {
  display:flex;
  gap:8px;
  flex-wrap: wrap;
}

/* Misc */
.hint {
  color:var(--muted);
  font-size:13px;
}
.foot {
  margin-top:10px;
  text-align:center;
  font-size:0.85rem;
  color:var(--muted);
}

/* ✅ Responsive for phones */
@media (max-width:600px) {
  .container {
    margin:10px;
    padding:12px;
    border-radius:12px;
  }

  .group-bar {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction:column;
  }

  .btn {
    width:100%;
    font-size:0.85rem;
    padding:8px 10px;
  }

  .table th, .table td {
    font-size:0.85rem;
    padding:6px;
  }

  .chip {
    padding:5px 8px;
    font-size:0.85rem;
  }
}
